author | zautrix <zautrix> | 2004-10-25 23:41:23 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-25 23:41:23 (UTC) |
commit | 8cc5f6491c0f0f1ad6568b8c6221ca8cdeac3207 (patch) (unidiff) | |
tree | 5909f33560e1ee90cc488cb4533c04bc2d259968 | |
parent | 7bf9517920766c9cd5e032af9cdd1e07d6604b6b (diff) | |
download | kdepimpi-8cc5f6491c0f0f1ad6568b8c6221ca8cdeac3207.zip kdepimpi-8cc5f6491c0f0f1ad6568b8c6221ca8cdeac3207.tar.gz kdepimpi-8cc5f6491c0f0f1ad6568b8c6221ca8cdeac3207.tar.bz2 |
kopiemail fixes
-rw-r--r-- | kmicromail/composemail.cpp | 6 |
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 | |||
@@ -1,494 +1,496 @@ | |||
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 <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; |
42 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) | 42 | ComposeMail::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 | ||
141 | void ComposeMail::fillSettings() | 143 | void 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 | ||
155 | void ComposeMail::saveAsDraft() | 157 | void 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 | } |
192 | void ComposeMail::clearStatus() | 194 | void ComposeMail::clearStatus() |
193 | { | 195 | { |
194 | topLevelWidget()->setCaption( i18n("Compose mail") ); | 196 | topLevelWidget()->setCaption( i18n("Compose mail") ); |
195 | } | 197 | } |
196 | void ComposeMail::setStatus( QString status ) | 198 | void 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 | } |
201 | void ComposeMail::pickAddress( ) | 203 | void 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()) { |
215 | if ( ! names.isEmpty() ) | 217 | if ( ! names.isEmpty() ) |
216 | names+= ","; | 218 | names+= ","; |
217 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; | 219 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; |
218 | 220 | ||
219 | } | 221 | } |
220 | } | 222 | } |
221 | 223 | ||
222 | 224 | ||
223 | if ( line->text().isEmpty() ) { | 225 | if ( line->text().isEmpty() ) { |
224 | line->setText( names ); | 226 | line->setText( names ); |
225 | } else if ( !names.isEmpty() ) { | 227 | } else if ( !names.isEmpty() ) { |
226 | line->setText( line->text() + ", " + names ); | 228 | line->setText( line->text() + ", " + names ); |
227 | } | 229 | } |
228 | #else | 230 | #else |
229 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); | 231 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); |
230 | // the result should now arrive through method insertAttendees | 232 | // the result should now arrive through method insertAttendees |
231 | #endif | 233 | #endif |
232 | } | 234 | } |
233 | //the map includes name/email pairs, that comes from Ka/Pi | 235 | //the map includes name/email pairs, that comes from Ka/Pi |
234 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 236 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
235 | { | 237 | { |
236 | //qDebug("ComposeMail::insertAttendees "); | 238 | //qDebug("ComposeMail::insertAttendees "); |
237 | raise(); | 239 | raise(); |
238 | 240 | ||
239 | if ( mPickLineEdit == 0 ) { //whoami received | 241 | if ( mPickLineEdit == 0 ) { //whoami received |
240 | QString defmail = uidList[0]; | 242 | QString defmail = uidList[0]; |
241 | if ( emailList.count() == 0 ) | 243 | if ( emailList.count() == 0 ) |
242 | QMessageBox::information( 0, i18n( "Hint" ), | 244 | QMessageBox::information( 0, i18n( "Hint" ), |
243 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 245 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
244 | i18n( "Ok" ) ); | 246 | i18n( "Ok" ) ); |
245 | if (defmail.length()!=0) { | 247 | if (defmail.length()!=0) { |
246 | fromBox->insertItem(defmail); | 248 | fromBox->insertItem(defmail); |
247 | } | 249 | } |
248 | QStringList::ConstIterator sit = emailList.begin(); | 250 | QStringList::ConstIterator sit = emailList.begin(); |
249 | int pref = 0; | 251 | int pref = 0; |
250 | for (;sit!=emailList.end();++sit) { | 252 | for (;sit!=emailList.end();++sit) { |
251 | if ( (*sit)==defmail) | 253 | if ( (*sit)==defmail) |
252 | continue; | 254 | continue; |
253 | fromBox->insertItem((*sit)); | 255 | fromBox->insertItem((*sit)); |
254 | } | 256 | } |
255 | senderNameEdit->setText(nameList[0]); | 257 | senderNameEdit->setText(nameList[0]); |
256 | return; | 258 | return; |
257 | } | 259 | } |
258 | QString names ; | 260 | QString names ; |
259 | QLineEdit *line = mPickLineEdit; | 261 | QLineEdit *line = mPickLineEdit; |
260 | if (uid == this->name()) | 262 | if (uid == this->name()) |
261 | { | 263 | { |
262 | for ( int i = 0; i < nameList.count(); i++) | 264 | for ( int i = 0; i < nameList.count(); i++) |
263 | { | 265 | { |
264 | QString _name = nameList[i]; | 266 | QString _name = nameList[i]; |
265 | QString _email = emailList[i]; | 267 | QString _email = emailList[i]; |
266 | QString _uid = uidList[i]; | 268 | QString _uid = uidList[i]; |
267 | if ( ! _email.isEmpty() ) { | 269 | if ( ! _email.isEmpty() ) { |
268 | if ( ! names.isEmpty() ) | 270 | if ( ! names.isEmpty() ) |
269 | names+= ","; | 271 | names+= ","; |
270 | names+= "\""+_name +"\"<" +_email +">"; | 272 | names+= "\""+_name +"\"<" +_email +">"; |
271 | } | 273 | } |
272 | } | 274 | } |
273 | } | 275 | } |
274 | if ( line->text().isEmpty() ) { | 276 | if ( line->text().isEmpty() ) { |
275 | line->setText( names ); | 277 | line->setText( names ); |
276 | } else if ( !names.isEmpty() ) { | 278 | } else if ( !names.isEmpty() ) { |
277 | line->setText( line->text() + ", " + names ); | 279 | line->setText( line->text() + ", " + names ); |
278 | } | 280 | } |
279 | } | 281 | } |
280 | 282 | ||
281 | void ComposeMail::setTo( const QString & to ) | 283 | void ComposeMail::setTo( const QString & to ) |
282 | { | 284 | { |
283 | toLine->setText( to ); | 285 | toLine->setText( to ); |
284 | } | 286 | } |
285 | 287 | ||
286 | void ComposeMail::setSubject( const QString & subject ) | 288 | void ComposeMail::setSubject( const QString & subject ) |
287 | { | 289 | { |
288 | subjectLine->setText( subject ); | 290 | subjectLine->setText( subject ); |
289 | } | 291 | } |
290 | 292 | ||
291 | void ComposeMail::setInReplyTo( const QString & messageId ) | 293 | void ComposeMail::setInReplyTo( const QString & messageId ) |
292 | { | 294 | { |
293 | m_replyid = messageId; | 295 | m_replyid = messageId; |
294 | } | 296 | } |
295 | 297 | ||
296 | void ComposeMail::setMessage( const QString & text ) | 298 | void ComposeMail::setMessage( const QString & text ) |
297 | { | 299 | { |
298 | message->setText( text ); | 300 | message->setText( text ); |
299 | } | 301 | } |
300 | 302 | ||
301 | 303 | ||
302 | void ComposeMail::pickAddressTo() | 304 | void ComposeMail::pickAddressTo() |
303 | { | 305 | { |
304 | mPickLineEdit = toLine; | 306 | mPickLineEdit = toLine; |
305 | pickAddress( ); | 307 | pickAddress( ); |
306 | } | 308 | } |
307 | 309 | ||
308 | void ComposeMail::pickAddressCC() | 310 | void ComposeMail::pickAddressCC() |
309 | { | 311 | { |
310 | mPickLineEdit = ccLine; | 312 | mPickLineEdit = ccLine; |
311 | pickAddress( ); | 313 | pickAddress( ); |
312 | } | 314 | } |
313 | 315 | ||
314 | void ComposeMail::pickAddressBCC() | 316 | void ComposeMail::pickAddressBCC() |
315 | { | 317 | { |
316 | mPickLineEdit = bccLine; | 318 | mPickLineEdit = bccLine; |
317 | pickAddress( ); | 319 | pickAddress( ); |
318 | } | 320 | } |
319 | 321 | ||
320 | void ComposeMail::pickAddressReply() | 322 | void ComposeMail::pickAddressReply() |
321 | { | 323 | { |
322 | mPickLineEdit = replyLine; | 324 | mPickLineEdit = replyLine; |
323 | pickAddress( ); | 325 | pickAddress( ); |
324 | } | 326 | } |
325 | 327 | ||
326 | void ComposeMail::fillValues( int ) | 328 | void ComposeMail::fillValues( int ) |
327 | { | 329 | { |
328 | #if 0 | 330 | #if 0 |
329 | SMTPaccount *smtp = smtpAccounts.at( current ); | 331 | SMTPaccount *smtp = smtpAccounts.at( current ); |
330 | ccLine->clear(); | 332 | ccLine->clear(); |
331 | if ( smtp->getUseCC() ) { | 333 | if ( smtp->getUseCC() ) { |
332 | ccLine->setText( smtp->getCC() ); | 334 | ccLine->setText( smtp->getCC() ); |
333 | } | 335 | } |
334 | bccLine->clear(); | 336 | bccLine->clear(); |
335 | if ( smtp->getUseBCC() ) { | 337 | if ( smtp->getUseBCC() ) { |
336 | bccLine->setText( smtp->getBCC() ); | 338 | bccLine->setText( smtp->getBCC() ); |
337 | } | 339 | } |
338 | replyLine->clear(); | 340 | replyLine->clear(); |
339 | if ( smtp->getUseReply() ) { | 341 | if ( smtp->getUseReply() ) { |
340 | replyLine->setText( smtp->getReply() ); | 342 | replyLine->setText( smtp->getReply() ); |
341 | } | 343 | } |
342 | sigMultiLine->setText( smtp->getSignature() ); | 344 | sigMultiLine->setText( smtp->getSignature() ); |
343 | #endif | 345 | #endif |
344 | } | 346 | } |
345 | 347 | ||
346 | void ComposeMail::slotAdjustColumns() | 348 | void ComposeMail::slotAdjustColumns() |
347 | { | 349 | { |
348 | int currPage = tabWidget->currentPageIndex(); | 350 | int currPage = tabWidget->currentPageIndex(); |
349 | 351 | ||
350 | tabWidget->showPage( attachTab ); | 352 | tabWidget->showPage( attachTab ); |
351 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 353 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
352 | attList->setColumnWidth( 1, 80 ); | 354 | attList->setColumnWidth( 1, 80 ); |
353 | 355 | ||
354 | tabWidget->setCurrentPage( currPage ); | 356 | tabWidget->setCurrentPage( currPage ); |
355 | } | 357 | } |
356 | 358 | ||
357 | void ComposeMail::addAttachment() | 359 | void ComposeMail::addAttachment() |
358 | { | 360 | { |
359 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); | 361 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); |
360 | if ( !lnk.isEmpty() ) { | 362 | if ( !lnk.isEmpty() ) { |
361 | Attachment *att = new Attachment( lnk ); | 363 | Attachment *att = new Attachment( lnk ); |
362 | (void) new AttachViewItem( attList, att ); | 364 | (void) new AttachViewItem( attList, att ); |
363 | } | 365 | } |
364 | } | 366 | } |
365 | 367 | ||
366 | void ComposeMail::removeAttachment() | 368 | void ComposeMail::removeAttachment() |
367 | { | 369 | { |
368 | if ( !attList->currentItem() ) { | 370 | if ( !attList->currentItem() ) { |
369 | QMessageBox::information( this, i18n( "Error" ), | 371 | QMessageBox::information( this, i18n( "Error" ), |
370 | i18n( "<p>Please select a File.</p>" ), | 372 | i18n( "<p>Please select a File.</p>" ), |
371 | i18n( "Ok" ) ); | 373 | i18n( "Ok" ) ); |
372 | } else { | 374 | } else { |
373 | attList->takeItem( attList->currentItem() ); | 375 | attList->takeItem( attList->currentItem() ); |
374 | } | 376 | } |
375 | } | 377 | } |
376 | 378 | ||
377 | void ComposeMail::accept() | 379 | void ComposeMail::accept() |
378 | { | 380 | { |
379 | if ( smtpAccountBox->count() == 0 ) { | 381 | if ( smtpAccountBox->count() == 0 ) { |
380 | 382 | ||
381 | reject(); | 383 | reject(); |
382 | return; | 384 | return; |
383 | } | 385 | } |
384 | 386 | ||
385 | if (! checkBoxLater->isChecked() ) { | 387 | if (! checkBoxLater->isChecked() ) { |
386 | int yesno = QMessageBox::warning(0,i18n("Stop editing message"), | 388 | int yesno = QMessageBox::warning(0,i18n("Stop editing message"), |
387 | i18n("Send this message?"), | 389 | i18n("Send this message?"), |
388 | i18n("Yes"), | 390 | i18n("Yes"), |
389 | i18n("Cancel")); | 391 | i18n("Cancel")); |
390 | 392 | ||
391 | if (yesno == 1) { | 393 | if (yesno == 1) { |
392 | return; | 394 | return; |
393 | } | 395 | } |
394 | } | 396 | } |
395 | #if 0 | 397 | #if 0 |
396 | odebug << "Sending Mail with " | 398 | odebug << "Sending Mail with " |
397 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; | 399 | << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; |
398 | #endif | 400 | #endif |
399 | Opie::Core::OSmartPointer<Mail> mail=new Mail; | 401 | Opie::Core::OSmartPointer<Mail> mail=new Mail; |
400 | 402 | ||
401 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 403 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
402 | mail->setMail(fromBox->currentText()); | 404 | mail->setMail(fromBox->currentText()); |
403 | 405 | ||
404 | if ( !toLine->text().isEmpty() ) { | 406 | if ( !toLine->text().isEmpty() ) { |
405 | mail->setTo( toLine->text() ); | 407 | mail->setTo( toLine->text() ); |
406 | } else { | 408 | } else { |
407 | QMessageBox::warning(0,i18n("Sending mail"), | 409 | QMessageBox::warning(0,i18n("Sending mail"), |
408 | i18n("No Receiver spezified" ) ); | 410 | i18n("No Receiver spezified" ) ); |
409 | return; | 411 | return; |
410 | } | 412 | } |
411 | 413 | ||
412 | mail->setName(senderNameEdit->text()); | 414 | mail->setName(senderNameEdit->text()); |
413 | mail->setCC( ccLine->text() ); | 415 | mail->setCC( ccLine->text() ); |
414 | mail->setBCC( bccLine->text() ); | 416 | mail->setBCC( bccLine->text() ); |
415 | mail->setReply( replyLine->text() ); | 417 | mail->setReply( replyLine->text() ); |
416 | mail->setSubject( subjectLine->text() ); | 418 | mail->setSubject( subjectLine->text() ); |
417 | if (!m_replyid.isEmpty()) { | 419 | if (!m_replyid.isEmpty()) { |
418 | QStringList ids; | 420 | QStringList ids; |
419 | ids.append(m_replyid); | 421 | ids.append(m_replyid); |
420 | mail->setInreply(ids); | 422 | mail->setInreply(ids); |
421 | } | 423 | } |
422 | QString txt = message->text(); | 424 | QString txt = message->text(); |
423 | if ( !sigMultiLine->text().isEmpty() ) { | 425 | if ( !sigMultiLine->text().isEmpty() ) { |
424 | txt.append( "\n--\n" ); | 426 | txt.append( "\n--\n" ); |
425 | txt.append( sigMultiLine->text() ); | 427 | txt.append( sigMultiLine->text() ); |
426 | } | 428 | } |
427 | mail->setMessage( txt ); | 429 | mail->setMessage( txt ); |
428 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 430 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
429 | while ( it != 0 ) { | 431 | while ( it != 0 ) { |
430 | mail->addAttachment( it->getAttachment() ); | 432 | mail->addAttachment( it->getAttachment() ); |
431 | it = (AttachViewItem *) it->nextSibling(); | 433 | it = (AttachViewItem *) it->nextSibling(); |
432 | } | 434 | } |
433 | 435 | ||
434 | SMTPwrapper wrapper( smtp ); | 436 | SMTPwrapper wrapper( smtp ); |
435 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) | 437 | if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) |
436 | setStatus( tr ("Mail sent")); | 438 | setStatus( tr ("Mail sent")); |
437 | else { | 439 | else { |
438 | setStatus( tr ("Error: Something went wrong. Nothing sent")); | 440 | setStatus( tr ("Error: Something went wrong. Nothing sent")); |
439 | return; | 441 | return; |
440 | } | 442 | } |
441 | 443 | ||
442 | 444 | ||
443 | QDialog::accept(); | 445 | QDialog::accept(); |
444 | } | 446 | } |
445 | 447 | ||
446 | void ComposeMail::reject() | 448 | void ComposeMail::reject() |
447 | { | 449 | { |
448 | //qDebug("ComposeMail::reject() "); | 450 | //qDebug("ComposeMail::reject() "); |
449 | int yesno = QMessageBox::warning(0,i18n("Store message?"), | 451 | int yesno = QMessageBox::warning(0,i18n("Store message?"), |
450 | i18n("Store message into drafts?\n"), | 452 | i18n("Store message into drafts?\n"), |
451 | i18n("Yes"), | 453 | i18n("Yes"), |
452 | i18n("No")); | 454 | i18n("No")); |
453 | 455 | ||
454 | //qDebug("button %d ", yesno); | 456 | //qDebug("button %d ", yesno); |
455 | if (yesno == 0) { | 457 | if (yesno == 0) { |
456 | if ( toLine->text().isEmpty() ) { | 458 | if ( toLine->text().isEmpty() ) { |
457 | QMessageBox::warning(0,i18n("Sending mail"), | 459 | QMessageBox::warning(0,i18n("Sending mail"), |
458 | i18n("No Receiver spezified" ) ); | 460 | i18n("No Receiver spezified" ) ); |
459 | return; | 461 | return; |
460 | } | 462 | } |
461 | saveAsDraft(); | 463 | saveAsDraft(); |
462 | } | 464 | } |
463 | if (yesno == 2) { | 465 | if (yesno == 2) { |
464 | qDebug("return "); | 466 | qDebug("return "); |
465 | return; | 467 | return; |
466 | } | 468 | } |
467 | QDialog::reject(); | 469 | QDialog::reject(); |
468 | } | 470 | } |
469 | 471 | ||
470 | ComposeMail::~ComposeMail() | 472 | ComposeMail::~ComposeMail() |
471 | { | 473 | { |
472 | } | 474 | } |
473 | 475 | ||
474 | void ComposeMail::reEditMail(const RecMailP¤t) | 476 | void ComposeMail::reEditMail(const RecMailP¤t) |
475 | { | 477 | { |
476 | RecMailP data = current; | 478 | RecMailP data = current; |
477 | message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); | 479 | message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); |
478 | subjectLine->setText( data->getSubject()); | 480 | subjectLine->setText( data->getSubject()); |
479 | toLine->setText(data->To().join(",")); | 481 | toLine->setText(data->To().join(",")); |
480 | ccLine->setText(data->CC().join(",")); | 482 | ccLine->setText(data->CC().join(",")); |
481 | bccLine->setText(data->Bcc().join(",")); | 483 | bccLine->setText(data->Bcc().join(",")); |
482 | replyLine->setText(data->Replyto()); | 484 | replyLine->setText(data->Replyto()); |
483 | } | 485 | } |
484 | 486 | ||
485 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 487 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
486 | : QListViewItem( parent ) | 488 | : QListViewItem( parent ) |
487 | { | 489 | { |
488 | attachment = att; | 490 | attachment = att; |
489 | if ( !attachment->getPixmap().isNull() ) | 491 | if ( !attachment->getPixmap().isNull() ) |
490 | setPixmap( 0,attachment->getPixmap() ); | 492 | setPixmap( 0,attachment->getPixmap() ); |
491 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); | 493 | setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); |
492 | setText( 1, QString::number( att->getSize() ) ); | 494 | setText( 1, QString::number( att->getSize() ) ); |
493 | } | 495 | } |
494 | 496 | ||