-rw-r--r-- | kmicromail/opiemail.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 197f7ec..b701446 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,677 +1,675 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | 3 | ||
4 | 4 | ||
5 | #define protected public | 5 | #define protected public |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #undef protected | 7 | #undef protected |
8 | #include "koprefsdialog.h" | 8 | #include "koprefsdialog.h" |
9 | #include <kapplication.h> | 9 | #include <kapplication.h> |
10 | #include <libkdepim/externalapphandler.h> | 10 | #include <libkdepim/externalapphandler.h> |
11 | #include <libkdepim/kpimglobalprefs.h> | 11 | #include <libkdepim/kpimglobalprefs.h> |
12 | #ifdef MINIKDE_KDIALOG_H | 12 | #ifdef MINIKDE_KDIALOG_H |
13 | #undef MINIKDE_KDIALOG_H | 13 | #undef MINIKDE_KDIALOG_H |
14 | #endif | 14 | #endif |
15 | #include "settingsdialog.h" | 15 | #include "settingsdialog.h" |
16 | #include "opiemail.h" | 16 | #include "opiemail.h" |
17 | #include "editaccounts.h" | 17 | #include "editaccounts.h" |
18 | #include "composemail.h" | 18 | #include "composemail.h" |
19 | #include "mailistviewitem.h" | 19 | #include "mailistviewitem.h" |
20 | #include "viewmail.h" | 20 | #include "viewmail.h" |
21 | #include "selectstore.h" | 21 | #include "selectstore.h" |
22 | #include "selectsmtp.h" | 22 | #include "selectsmtp.h" |
23 | #include "accountitem.h" | 23 | #include "accountitem.h" |
24 | #include "accountview.h" | 24 | #include "accountview.h" |
25 | #include "klocale.h" | 25 | #include "klocale.h" |
26 | 26 | ||
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qcursor.h> | 29 | #include <qcursor.h> |
30 | #include <qtextbrowser.h> | 30 | #include <qtextbrowser.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | 33 | ||
34 | #ifdef DESKTOP_VERSION | 34 | #ifdef DESKTOP_VERSION |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #else | 36 | #else |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #endif | 38 | #endif |
39 | #include <libmailwrapper/smtpwrapper.h> | 39 | #include <libmailwrapper/smtpwrapper.h> |
40 | #include <libmailwrapper/mailtypes.h> | 40 | #include <libmailwrapper/mailtypes.h> |
41 | #include <libmailwrapper/abstractmail.h> | 41 | #include <libmailwrapper/abstractmail.h> |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | 43 | ||
44 | //using namespace Opie::Core; | 44 | //using namespace Opie::Core; |
45 | 45 | ||
46 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 46 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
48 | { | 48 | { |
49 | mCurrentComposer = 0; | 49 | mCurrentComposer = 0; |
50 | settings = new Settings(); | 50 | settings = new Settings(); |
51 | tb = 0; | 51 | tb = 0; |
52 | setIcon(SmallIcon( "kmicromail" ) ); | 52 | setIcon(SmallIcon( "kmicromail" ) ); |
53 | folderView->populate( settings->getAccounts() ); | 53 | folderView->populate( settings->getAccounts() ); |
54 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 54 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
55 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 55 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
56 | } | 56 | } |
57 | 57 | ||
58 | OpieMail::~OpieMail() | 58 | OpieMail::~OpieMail() |
59 | { | 59 | { |
60 | if (settings) delete settings; | 60 | if (settings) delete settings; |
61 | if ( tb ) | 61 | if ( tb ) |
62 | delete tb; | 62 | delete tb; |
63 | } | 63 | } |
64 | 64 | ||
65 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 65 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
66 | { | 66 | { |
67 | 67 | ||
68 | } | 68 | } |
69 | #include <stdlib.h> | 69 | #include <stdlib.h> |
70 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 70 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
71 | { | 71 | { |
72 | // copied from old mail2 | 72 | // copied from old mail2 |
73 | static int ii = 0; | 73 | static int ii = 0; |
74 | //qDebug("QCOP CALL ############################# %d ", ii); | 74 | //qDebug("QCOP CALL ############################# %d ", ii); |
75 | //QString mess ( msg ); | 75 | //QString mess ( msg ); |
76 | //qDebug("Message = %s ",mess.latin1()); | 76 | //qDebug("Message = %s ",mess.latin1()); |
77 | ++ii; | 77 | ++ii; |
78 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 78 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
79 | 79 | ||
80 | mPendingEmail = QString::null; | 80 | mPendingEmail = QString::null; |
81 | mPendingName = QString::null; | 81 | mPendingName = QString::null; |
82 | if (msg == "writeMail(QString,QString)") | 82 | if (msg == "writeMail(QString,QString)") |
83 | { | 83 | { |
84 | //qDebug("writeMail(QString,QString) "); | 84 | //qDebug("writeMail(QString,QString) "); |
85 | QDataStream stream(data,IO_ReadOnly); | 85 | QDataStream stream(data,IO_ReadOnly); |
86 | stream >> mPendingName >> mPendingEmail; | 86 | stream >> mPendingName >> mPendingEmail; |
87 | // removing the whitespaces at beginning and end is needed! | 87 | // removing the whitespaces at beginning and end is needed! |
88 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 88 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
89 | } | 89 | } |
90 | else if (msg == "newMail()") | 90 | else if (msg == "newMail()") |
91 | { | 91 | { |
92 | //qDebug("slotComposeMail() "); | 92 | //qDebug("slotComposeMail() "); |
93 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 93 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
94 | // and a QCOP call does not like a processevents in his execution | 94 | // and a QCOP call does not like a processevents in his execution |
95 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 95 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
97 | // slotComposeMail(); | 97 | // slotComposeMail(); |
98 | } | 98 | } |
99 | else if (msg == "newMail(QString)") | 99 | else if (msg == "newMail(QString)") |
100 | { | 100 | { |
101 | //qDebug(" newMail(QString)"); | 101 | //qDebug(" newMail(QString)"); |
102 | QDataStream stream(data,IO_ReadOnly); | 102 | QDataStream stream(data,IO_ReadOnly); |
103 | stream >> mPendingName; | 103 | stream >> mPendingName; |
104 | // the format is | 104 | // the format is |
105 | // NAME <EMAIL>:SUBJECT | 105 | // NAME <EMAIL>:SUBJECT |
106 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 106 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
107 | } else { | 107 | } else { |
108 | mPendingData = data; | 108 | mPendingData = data; |
109 | mPendingMessage = msg; | 109 | mPendingMessage = msg; |
110 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 110 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
111 | } | 111 | } |
112 | 112 | ||
113 | //qDebug("END OpieMail::message "); | 113 | //qDebug("END OpieMail::message "); |
114 | } | 114 | } |
115 | void OpieMail::slotExtAppHandler() | 115 | void OpieMail::slotExtAppHandler() |
116 | { | 116 | { |
117 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 117 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
118 | } | 118 | } |
119 | void OpieMail::slotwriteMail2(const QString& namemail ) | 119 | void OpieMail::slotwriteMail2(const QString& namemail ) |
120 | { | 120 | { |
121 | //qDebug("OpieMail::slotwriteMail2 "); | 121 | //qDebug("OpieMail::slotwriteMail2 "); |
122 | //qApp->processEvents(); | 122 | //qApp->processEvents(); |
123 | ComposeMail compose( settings, this, 0, true ); | 123 | ComposeMail compose( settings, this, 0, true ); |
124 | if ( !namemail.isEmpty() ) { | 124 | if ( !namemail.isEmpty() ) { |
125 | QString to = namemail; | 125 | QString to = namemail; |
126 | if ( namemail.find( " <") > 1 ) { | 126 | if ( namemail.find( " <") > 1 ) { |
127 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 127 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
128 | } else | 128 | } else |
129 | if ( namemail.find( "<") > 1 ) { | 129 | if ( namemail.find( "<") > 1 ) { |
130 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 130 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
131 | } | 131 | } |
132 | int sub = to.find( ">:"); | 132 | int sub = to.find( ">:"); |
133 | if ( sub > 0 ) { | 133 | if ( sub > 0 ) { |
134 | compose.setTo( to.left(sub+1) ); | 134 | compose.setTo( to.left(sub+1) ); |
135 | compose.setSubject( to.mid(sub+2) ); | 135 | compose.setSubject( to.mid(sub+2) ); |
136 | } else | 136 | } else |
137 | compose.setTo( to ); | 137 | compose.setTo( to ); |
138 | } | 138 | } |
139 | compose.slotAdjustColumns(); | 139 | compose.slotAdjustColumns(); |
140 | #ifndef DESKTOP_VERSION | 140 | #ifndef DESKTOP_VERSION |
141 | compose.showMaximized(); | 141 | compose.showMaximized(); |
142 | #endif | 142 | #endif |
143 | mCurrentComposer = &compose; | 143 | mCurrentComposer = &compose; |
144 | compose.exec(); | 144 | compose.exec(); |
145 | mCurrentComposer = 0; | 145 | mCurrentComposer = 0; |
146 | folderView->refreshOutgoing(); | 146 | folderView->refreshOutgoing(); |
147 | raise(); | 147 | raise(); |
148 | //qDebug("retttich "); | 148 | //qDebug("retttich "); |
149 | } | 149 | } |
150 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 150 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
151 | { | 151 | { |
152 | // qDebug("OpieMail::slotwriteMail "); | 152 | // qDebug("OpieMail::slotwriteMail "); |
153 | ComposeMail compose( settings, this, 0, true ); | 153 | ComposeMail compose( settings, this, 0, true ); |
154 | if (!email.isEmpty()) | 154 | if (!email.isEmpty()) |
155 | { | 155 | { |
156 | if (!name.isEmpty()) | 156 | if (!name.isEmpty()) |
157 | { | 157 | { |
158 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 158 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
159 | } | 159 | } |
160 | else | 160 | else |
161 | { | 161 | { |
162 | compose.setTo(email); | 162 | compose.setTo(email); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | compose.slotAdjustColumns(); | 165 | compose.slotAdjustColumns(); |
166 | #ifndef DESKTOP_VERSION | 166 | #ifndef DESKTOP_VERSION |
167 | compose.showMaximized(); | 167 | compose.showMaximized(); |
168 | #endif | 168 | #endif |
169 | 169 | ||
170 | mCurrentComposer = &compose; | 170 | mCurrentComposer = &compose; |
171 | compose.exec(); | 171 | compose.exec(); |
172 | mCurrentComposer = 0; | 172 | mCurrentComposer = 0; |
173 | folderView->refreshOutgoing(); | 173 | folderView->refreshOutgoing(); |
174 | raise(); | 174 | raise(); |
175 | } | 175 | } |
176 | 176 | ||
177 | void OpieMail::slotComposeMail() | 177 | void OpieMail::slotComposeMail() |
178 | { | 178 | { |
179 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 179 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
180 | slotwriteMail2( QString () ); | 180 | slotwriteMail2( QString () ); |
181 | else { | 181 | else { |
182 | if ( mPendingEmail == QString::null ) | 182 | if ( mPendingEmail == QString::null ) |
183 | slotwriteMail2( mPendingName ); | 183 | slotwriteMail2( mPendingName ); |
184 | else | 184 | else |
185 | slotwriteMail( mPendingName, mPendingEmail ); | 185 | slotwriteMail( mPendingName, mPendingEmail ); |
186 | } | 186 | } |
187 | //slotwriteMail(0l,0l); | 187 | //slotwriteMail(0l,0l); |
188 | } | 188 | } |
189 | 189 | ||
190 | void OpieMail::slotSendQueued() | 190 | void OpieMail::slotSendQueued() |
191 | { | 191 | { |
192 | SMTPaccount *smtp = 0; | 192 | SMTPaccount *smtp = 0; |
193 | 193 | ||
194 | QList<Account> list = settings->getAccounts(); | 194 | QList<Account> list = settings->getAccounts(); |
195 | QList<SMTPaccount> smtpList; | 195 | QList<SMTPaccount> smtpList; |
196 | smtpList.setAutoDelete(false); | 196 | smtpList.setAutoDelete(false); |
197 | Account *it; | 197 | Account *it; |
198 | for ( it = list.first(); it; it = list.next() ) | 198 | for ( it = list.first(); it; it = list.next() ) |
199 | { | 199 | { |
200 | if ( it->getType() == MAILLIB::A_SMTP ) | 200 | if ( it->getType() == MAILLIB::A_SMTP ) |
201 | { | 201 | { |
202 | smtp = static_cast<SMTPaccount *>(it); | 202 | smtp = static_cast<SMTPaccount *>(it); |
203 | smtpList.append(smtp); | 203 | smtpList.append(smtp); |
204 | } | 204 | } |
205 | } | 205 | } |
206 | if (smtpList.count()==0) | 206 | if (smtpList.count()==0) |
207 | { | 207 | { |
208 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 208 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n")); |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 211 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to\nsend all queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
212 | return; | 212 | return; |
213 | if (smtpList.count()==1) | 213 | if (smtpList.count()==1) |
214 | { | 214 | { |
215 | smtp = smtpList.at(0); | 215 | smtp = smtpList.at(0); |
216 | } | 216 | } |
217 | else | 217 | else |
218 | { | 218 | { |
219 | smtp = 0; | 219 | smtp = 0; |
220 | selectsmtp selsmtp; | 220 | selectsmtp selsmtp; |
221 | selsmtp.setSelectionlist(&smtpList); | 221 | selsmtp.setSelectionlist(&smtpList); |
222 | #ifndef DESKTOP_VERSION | 222 | selsmtp.resize( selsmtp.sizeHint() ); |
223 | selsmtp.showMaximized(); | ||
224 | #endif | ||
225 | if ( selsmtp.exec() == QDialog::Accepted ) | 223 | if ( selsmtp.exec() == QDialog::Accepted ) |
226 | { | 224 | { |
227 | smtp = selsmtp.selected_smtp(); | 225 | smtp = selsmtp.selected_smtp(); |
228 | } | 226 | } |
229 | } | 227 | } |
230 | if (smtp) | 228 | if (smtp) |
231 | { | 229 | { |
232 | 230 | ||
233 | Global::statusMessage("Sending mails...!"); | 231 | Global::statusMessage("Sending mails...!"); |
234 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 232 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
235 | if ( wrap->flushOutbox() ) | 233 | if ( wrap->flushOutbox() ) |
236 | { | 234 | { |
237 | Global::statusMessage("Mails sent!"); | 235 | Global::statusMessage("Mails sent!"); |
238 | } | 236 | } |
239 | delete wrap; | 237 | delete wrap; |
240 | } | 238 | } |
241 | folderView->refreshOutgoing(); | 239 | folderView->refreshOutgoing(); |
242 | } | 240 | } |
243 | 241 | ||
244 | void OpieMail::slotSearchMails() | 242 | void OpieMail::slotSearchMails() |
245 | { | 243 | { |
246 | qDebug("OpieMail::slotSearchMails():not implemented "); | 244 | qDebug("OpieMail::slotSearchMails():not implemented "); |
247 | } | 245 | } |
248 | 246 | ||
249 | void OpieMail::slotEditSettings() | 247 | void OpieMail::slotEditSettings() |
250 | { | 248 | { |
251 | 249 | ||
252 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 250 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
253 | #ifndef DESKTOP_VERSION | 251 | #ifndef DESKTOP_VERSION |
254 | settingsDialog.showMaximized(); | 252 | settingsDialog.showMaximized(); |
255 | #endif | 253 | #endif |
256 | settingsDialog.exec(); | 254 | settingsDialog.exec(); |
257 | 255 | ||
258 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 256 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
259 | // KApplication::execDialog(settingsDialog); | 257 | // KApplication::execDialog(settingsDialog); |
260 | } | 258 | } |
261 | 259 | ||
262 | void OpieMail::slotEditAccounts() | 260 | void OpieMail::slotEditAccounts() |
263 | { | 261 | { |
264 | EditAccounts eaDialog( settings, this, 0, true ); | 262 | EditAccounts eaDialog( settings, this, 0, true ); |
265 | eaDialog.slotAdjustColumns(); | 263 | eaDialog.slotAdjustColumns(); |
266 | #ifndef DESKTOP_VERSION | 264 | #ifndef DESKTOP_VERSION |
267 | eaDialog.showMaximized(); | 265 | eaDialog.showMaximized(); |
268 | #endif | 266 | #endif |
269 | eaDialog.exec(); | 267 | eaDialog.exec(); |
270 | if ( settings ) delete settings; | 268 | if ( settings ) delete settings; |
271 | settings = new Settings(); | 269 | settings = new Settings(); |
272 | 270 | ||
273 | folderView->populate( settings->getAccounts() ); | 271 | folderView->populate( settings->getAccounts() ); |
274 | } | 272 | } |
275 | void OpieMail::replyMail() | 273 | void OpieMail::replyMail() |
276 | { | 274 | { |
277 | 275 | ||
278 | QListViewItem*item = mailView->currentItem(); | 276 | QListViewItem*item = mailView->currentItem(); |
279 | if (!item) return; | 277 | if (!item) return; |
280 | RecMailP mail = ((MailListViewItem*)item)->data(); | 278 | RecMailP mail = ((MailListViewItem*)item)->data(); |
281 | RecBodyP body = folderView->fetchBody(mail); | 279 | RecBodyP body = folderView->fetchBody(mail); |
282 | 280 | ||
283 | QString rtext; | 281 | QString rtext; |
284 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 282 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
285 | .arg( mail->getFrom()) | 283 | .arg( mail->getFrom()) |
286 | .arg( mail->getDate()); | 284 | .arg( mail->getDate()); |
287 | 285 | ||
288 | QString text = body->Bodytext(); | 286 | QString text = body->Bodytext(); |
289 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 287 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
290 | QStringList::Iterator it; | 288 | QStringList::Iterator it; |
291 | for (it = lines.begin(); it != lines.end(); it++) | 289 | for (it = lines.begin(); it != lines.end(); it++) |
292 | { | 290 | { |
293 | rtext += "> " + *it + "\n"; | 291 | rtext += "> " + *it + "\n"; |
294 | } | 292 | } |
295 | rtext += "\n"; | 293 | rtext += "\n"; |
296 | 294 | ||
297 | QString prefix; | 295 | QString prefix; |
298 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 296 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
299 | else prefix = "Re: "; // no i18n on purpose | 297 | else prefix = "Re: "; // no i18n on purpose |
300 | 298 | ||
301 | Settings *settings = new Settings(); | 299 | Settings *settings = new Settings(); |
302 | ComposeMail composer( settings ,this, 0, true); | 300 | ComposeMail composer( settings ,this, 0, true); |
303 | if (mail->Replyto().isEmpty()) { | 301 | if (mail->Replyto().isEmpty()) { |
304 | composer.setTo( mail->getFrom()); | 302 | composer.setTo( mail->getFrom()); |
305 | } else { | 303 | } else { |
306 | composer.setTo( mail->Replyto()); | 304 | composer.setTo( mail->Replyto()); |
307 | } | 305 | } |
308 | composer.setSubject( prefix + mail->getSubject()); | 306 | composer.setSubject( prefix + mail->getSubject()); |
309 | composer.setMessage( rtext ); | 307 | composer.setMessage( rtext ); |
310 | composer.setInReplyTo( mail->Msgid()); | 308 | composer.setInReplyTo( mail->Msgid()); |
311 | composer.setCharset( body->getCharset() ); | 309 | composer.setCharset( body->getCharset() ); |
312 | 310 | ||
313 | mCurrentComposer = &composer; | 311 | mCurrentComposer = &composer; |
314 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 312 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
315 | { | 313 | { |
316 | mail->Wrapper()->answeredMail(mail); | 314 | mail->Wrapper()->answeredMail(mail); |
317 | } | 315 | } |
318 | mCurrentComposer = 0; | 316 | mCurrentComposer = 0; |
319 | folderView->refreshOutgoing(); | 317 | folderView->refreshOutgoing(); |
320 | delete settings; | 318 | delete settings; |
321 | 319 | ||
322 | } | 320 | } |
323 | void OpieMail::closeViewMail(ViewMail * vm) | 321 | void OpieMail::closeViewMail(ViewMail * vm) |
324 | { | 322 | { |
325 | vm->hide(); | 323 | vm->hide(); |
326 | } | 324 | } |
327 | 325 | ||
328 | void OpieMail::slotDownloadMail( ) | 326 | void OpieMail::slotDownloadMail( ) |
329 | { | 327 | { |
330 | QListViewItem*item = mailView->currentItem(); | 328 | QListViewItem*item = mailView->currentItem(); |
331 | if (!item ) { | 329 | if (!item ) { |
332 | Global::statusMessage("Error: No item slected!"); | 330 | Global::statusMessage("Error: No item slected!"); |
333 | return; | 331 | return; |
334 | } | 332 | } |
335 | RecMailP mail = ((MailListViewItem*)item)->data(); | 333 | RecMailP mail = ((MailListViewItem*)item)->data(); |
336 | Account * acc = mail->Wrapper()->getAccount(); | 334 | Account * acc = mail->Wrapper()->getAccount(); |
337 | if ( !acc ) { | 335 | if ( !acc ) { |
338 | Global::statusMessage("Mail is already stored locally!"); | 336 | Global::statusMessage("Mail is already stored locally!"); |
339 | return; | 337 | return; |
340 | } | 338 | } |
341 | QString lfName = acc->getLocalFolder(); | 339 | QString lfName = acc->getLocalFolder(); |
342 | //qDebug("local folder " + lfName ); | 340 | //qDebug("local folder " + lfName ); |
343 | if ( lfName.isEmpty() ) | 341 | if ( lfName.isEmpty() ) |
344 | lfName = acc->getAccountName(); | 342 | lfName = acc->getAccountName(); |
345 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); | 343 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); |
346 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); | 344 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); |
347 | if ( targetMail == mail->Wrapper() ) { | 345 | if ( targetMail == mail->Wrapper() ) { |
348 | Global::statusMessage("Mail is already locally stored!"); | 346 | Global::statusMessage("Mail is already locally stored!"); |
349 | return; | 347 | return; |
350 | } | 348 | } |
351 | if ( !targetMail->createMbox(lfName)) { | 349 | if ( !targetMail->createMbox(lfName)) { |
352 | Global::statusMessage("Error creating folder!"); | 350 | Global::statusMessage("Error creating folder!"); |
353 | return; | 351 | return; |
354 | } | 352 | } |
355 | Global::statusMessage("Fetching mail...please wait!"); | 353 | Global::statusMessage("Fetching mail...please wait!"); |
356 | qApp->processEvents(); | 354 | qApp->processEvents(); |
357 | encodedString*st = 0; | 355 | encodedString*st = 0; |
358 | st = mail->Wrapper()->fetchRawBody(mail); | 356 | st = mail->Wrapper()->fetchRawBody(mail); |
359 | if ( st ) { | 357 | if ( st ) { |
360 | targetMail->storeMessage(st->Content(),st->Length(),lfName); | 358 | targetMail->storeMessage(st->Content(),st->Length(),lfName); |
361 | Global::statusMessage("Mail stored in "+ lfName); | 359 | Global::statusMessage("Mail stored in "+ lfName); |
362 | delete st; | 360 | delete st; |
363 | } else { | 361 | } else { |
364 | Global::statusMessage("Error: Cannot fetch mail!"); | 362 | Global::statusMessage("Error: Cannot fetch mail!"); |
365 | } | 363 | } |
366 | } | 364 | } |
367 | 365 | ||
368 | 366 | ||
369 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) | 367 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) |
370 | { | 368 | { |
371 | QListViewItem*item = mailView->currentItem(); | 369 | QListViewItem*item = mailView->currentItem(); |
372 | if (!item ) { | 370 | if (!item ) { |
373 | closeViewMail(vm); | 371 | closeViewMail(vm); |
374 | return; | 372 | return; |
375 | } | 373 | } |
376 | RecMailP mail = ((MailListViewItem*)item)->data(); | 374 | RecMailP mail = ((MailListViewItem*)item)->data(); |
377 | mail->Wrapper()->deleteMail( mail ); | 375 | mail->Wrapper()->deleteMail( mail ); |
378 | item = item->itemBelow(); | 376 | item = item->itemBelow(); |
379 | if (!item ) { | 377 | if (!item ) { |
380 | closeViewMail(vm); | 378 | closeViewMail(vm); |
381 | return; | 379 | return; |
382 | } | 380 | } |
383 | mailView->setCurrentItem(item); | 381 | mailView->setCurrentItem(item); |
384 | mail = ((MailListViewItem*)item)->data(); | 382 | mail = ((MailListViewItem*)item)->data(); |
385 | RecBodyP body = folderView->fetchBody(mail); | 383 | RecBodyP body = folderView->fetchBody(mail); |
386 | vm->setBody( body ); | 384 | vm->setBody( body ); |
387 | vm->setMail( mail ); | 385 | vm->setMail( mail ); |
388 | } | 386 | } |
389 | void OpieMail::displayNextMail(ViewMail * vm) | 387 | void OpieMail::displayNextMail(ViewMail * vm) |
390 | { | 388 | { |
391 | QListViewItem*item = mailView->currentItem(); | 389 | QListViewItem*item = mailView->currentItem(); |
392 | if (!item) return; | 390 | if (!item) return; |
393 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 391 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
394 | item = item->itemBelow(); | 392 | item = item->itemBelow(); |
395 | if (!item) { | 393 | if (!item) { |
396 | vm->setCaption(i18n("End of List" )); | 394 | vm->setCaption(i18n("End of List" )); |
397 | return; | 395 | return; |
398 | } | 396 | } |
399 | mailView->setCurrentItem(item); | 397 | mailView->setCurrentItem(item); |
400 | RecMailP mail = ((MailListViewItem*)item)->data(); | 398 | RecMailP mail = ((MailListViewItem*)item)->data(); |
401 | RecBodyP body = folderView->fetchBody(mail); | 399 | RecBodyP body = folderView->fetchBody(mail); |
402 | vm->setBody( body ); | 400 | vm->setBody( body ); |
403 | vm->setMail( mail ); | 401 | vm->setMail( mail ); |
404 | } | 402 | } |
405 | void OpieMail::displayMail() | 403 | void OpieMail::displayMail() |
406 | { | 404 | { |
407 | QListViewItem*item = mailView->currentItem(); | 405 | QListViewItem*item = mailView->currentItem(); |
408 | if (!item) return; | 406 | if (!item) return; |
409 | RecMailP mail = ((MailListViewItem*)item)->data(); | 407 | RecMailP mail = ((MailListViewItem*)item)->data(); |
410 | RecBodyP body = folderView->fetchBody(mail); | 408 | RecBodyP body = folderView->fetchBody(mail); |
411 | ViewMail readMail( this,"", Qt::WType_Modal ); | 409 | ViewMail readMail( this,"", Qt::WType_Modal ); |
412 | readMail.setBody( body ); | 410 | readMail.setBody( body ); |
413 | readMail.setMail( mail ); | 411 | readMail.setMail( mail ); |
414 | #ifndef DESKTOP_VERSION | 412 | #ifndef DESKTOP_VERSION |
415 | readMail.showMaximized(); | 413 | readMail.showMaximized(); |
416 | #else | 414 | #else |
417 | readMail.resize( 640, 480); | 415 | readMail.resize( 640, 480); |
418 | #endif | 416 | #endif |
419 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); | 417 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); |
420 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); | 418 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); |
421 | connect( &readMail,SIGNAL( signalDownloadMail() ), this, SLOT( slotDownloadMail() ) ); | 419 | connect( &readMail,SIGNAL( signalDownloadMail() ), this, SLOT( slotDownloadMail() ) ); |
422 | 420 | ||
423 | readMail.exec(); | 421 | readMail.exec(); |
424 | 422 | ||
425 | if ( readMail.deleted ) | 423 | if ( readMail.deleted ) |
426 | { | 424 | { |
427 | folderView->refreshCurrent(); | 425 | folderView->refreshCurrent(); |
428 | } | 426 | } |
429 | else | 427 | else |
430 | { | 428 | { |
431 | QListViewItem*item = mailView->currentItem(); | 429 | QListViewItem*item = mailView->currentItem(); |
432 | if (item) | 430 | if (item) |
433 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 431 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
434 | } | 432 | } |
435 | } | 433 | } |
436 | void OpieMail::slotGetAllMail() | 434 | void OpieMail::slotGetAllMail() |
437 | { | 435 | { |
438 | QListViewItem * item = folderView->firstChild(); | 436 | QListViewItem * item = folderView->firstChild(); |
439 | while ( item ){ | 437 | while ( item ){ |
440 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 438 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
441 | item = item->nextSibling (); | 439 | item = item->nextSibling (); |
442 | } | 440 | } |
443 | } | 441 | } |
444 | void OpieMail::slotGetMail() | 442 | void OpieMail::slotGetMail() |
445 | { | 443 | { |
446 | QListViewItem * item = folderView->currentItem(); | 444 | QListViewItem * item = folderView->currentItem(); |
447 | if ( ! item ) return; | 445 | if ( ! item ) return; |
448 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 446 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
449 | } | 447 | } |
450 | void OpieMail::slotDeleteMail() | 448 | void OpieMail::slotDeleteMail() |
451 | { | 449 | { |
452 | if (!mailView->currentItem()) return; | 450 | if (!mailView->currentItem()) return; |
453 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 451 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
454 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 452 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
455 | { | 453 | { |
456 | mail->Wrapper()->deleteMail( mail ); | 454 | mail->Wrapper()->deleteMail( mail ); |
457 | folderView->refreshCurrent(); | 455 | folderView->refreshCurrent(); |
458 | } | 456 | } |
459 | } | 457 | } |
460 | void OpieMail::slotDeleteAllMail() | 458 | void OpieMail::slotDeleteAllMail() |
461 | { | 459 | { |
462 | 460 | ||
463 | QValueList<RecMailP> t; | 461 | QValueList<RecMailP> t; |
464 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 462 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
465 | { | 463 | { |
466 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 464 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
467 | while ( item ) { | 465 | while ( item ) { |
468 | if ( item->isSelected() ) { | 466 | if ( item->isSelected() ) { |
469 | t.append( item->data() ); | 467 | t.append( item->data() ); |
470 | } | 468 | } |
471 | item = (MailListViewItem*)item->nextSibling(); | 469 | item = (MailListViewItem*)item->nextSibling(); |
472 | } | 470 | } |
473 | } | 471 | } |
474 | else | 472 | else |
475 | return; | 473 | return; |
476 | if ( t.count() == 0 ) | 474 | if ( t.count() == 0 ) |
477 | return; | 475 | return; |
478 | RecMailP mail = t.first(); | 476 | RecMailP mail = t.first(); |
479 | mail->Wrapper()->deleteMailList(t); | 477 | mail->Wrapper()->deleteMailList(t); |
480 | folderView->refreshCurrent(); | 478 | folderView->refreshCurrent(); |
481 | 479 | ||
482 | 480 | ||
483 | } | 481 | } |
484 | void OpieMail::clearSelection() | 482 | void OpieMail::clearSelection() |
485 | { | 483 | { |
486 | mailView->clearSelection(); | 484 | mailView->clearSelection(); |
487 | 485 | ||
488 | } | 486 | } |
489 | 487 | ||
490 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 488 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
491 | { | 489 | { |
492 | if (!mailView->currentItem()) return; | 490 | if (!mailView->currentItem()) return; |
493 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 491 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
494 | /* just the RIGHT button - or hold on pda */ | 492 | /* just the RIGHT button - or hold on pda */ |
495 | if (button!=2) {return;} | 493 | if (button!=2) {return;} |
496 | if (!item) return; | 494 | if (!item) return; |
497 | QPopupMenu *m = new QPopupMenu(0); | 495 | QPopupMenu *m = new QPopupMenu(0); |
498 | if (m) | 496 | if (m) |
499 | { | 497 | { |
500 | if (mailtype==MAILLIB::A_NNTP) { | 498 | if (mailtype==MAILLIB::A_NNTP) { |
501 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); | 499 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); |
502 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 500 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
503 | m->insertSeparator(); | 501 | m->insertSeparator(); |
504 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); | 502 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); |
505 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 503 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
506 | } else { | 504 | } else { |
507 | if (folderView->currentisDraft()) { | 505 | if (folderView->currentisDraft()) { |
508 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); | 506 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); |
509 | } | 507 | } |
510 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); | 508 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); |
511 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); | 509 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); |
512 | m->insertSeparator(); | 510 | m->insertSeparator(); |
513 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 511 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
514 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); | 512 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); |
515 | m->insertSeparator(); | 513 | m->insertSeparator(); |
516 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 514 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
517 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 515 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
518 | m->insertSeparator(); | 516 | m->insertSeparator(); |
519 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 517 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
520 | } | 518 | } |
521 | m->setFocus(); | 519 | m->setFocus(); |
522 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 520 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
523 | delete m; | 521 | delete m; |
524 | } | 522 | } |
525 | } | 523 | } |
526 | 524 | ||
527 | void OpieMail::slotShowFolders( bool show ) | 525 | void OpieMail::slotShowFolders( bool show ) |
528 | { | 526 | { |
529 | if ( show && folderView->isHidden() ) | 527 | if ( show && folderView->isHidden() ) |
530 | { | 528 | { |
531 | folderView->show(); | 529 | folderView->show(); |
532 | } | 530 | } |
533 | else if ( !show && !folderView->isHidden() ) | 531 | else if ( !show && !folderView->isHidden() ) |
534 | { | 532 | { |
535 | folderView->hide(); | 533 | folderView->hide(); |
536 | } | 534 | } |
537 | } | 535 | } |
538 | 536 | ||
539 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 537 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
540 | { | 538 | { |
541 | MailListViewItem*item = 0; | 539 | MailListViewItem*item = 0; |
542 | mailView->clear(); | 540 | mailView->clear(); |
543 | 541 | ||
544 | QValueList<RecMailP>::ConstIterator it; | 542 | QValueList<RecMailP>::ConstIterator it; |
545 | for (it = list.begin(); it != list.end();++it) | 543 | for (it = list.begin(); it != list.end();++it) |
546 | { | 544 | { |
547 | item = new MailListViewItem(mailView,item); | 545 | item = new MailListViewItem(mailView,item); |
548 | item->storeData((*it)); | 546 | item->storeData((*it)); |
549 | item->showEntry(); | 547 | item->showEntry(); |
550 | } | 548 | } |
551 | mailView->setSorting ( 4, false ); | 549 | mailView->setSorting ( 4, false ); |
552 | } | 550 | } |
553 | 551 | ||
554 | void OpieMail::mailLeftClicked( QListViewItem *item ) | 552 | void OpieMail::mailLeftClicked( QListViewItem *item ) |
555 | { | 553 | { |
556 | mailView->clearSelection(); | 554 | mailView->clearSelection(); |
557 | /* just LEFT button - or tap with stylus on pda */ | 555 | /* just LEFT button - or tap with stylus on pda */ |
558 | //if (button!=1) return; | 556 | //if (button!=1) return; |
559 | if (!item) return; | 557 | if (!item) return; |
560 | if (folderView->currentisDraft()) { | 558 | if (folderView->currentisDraft()) { |
561 | reEditMail(); | 559 | reEditMail(); |
562 | } else { | 560 | } else { |
563 | displayMail(); | 561 | displayMail(); |
564 | } | 562 | } |
565 | } | 563 | } |
566 | 564 | ||
567 | void OpieMail::slotMoveCopyMail() | 565 | void OpieMail::slotMoveCopyMail() |
568 | { | 566 | { |
569 | if (!mailView->currentItem()) return; | 567 | if (!mailView->currentItem()) return; |
570 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 568 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
571 | AbstractMail*targetMail = 0; | 569 | AbstractMail*targetMail = 0; |
572 | QString targetFolder = ""; | 570 | QString targetFolder = ""; |
573 | Selectstore sels; | 571 | Selectstore sels; |
574 | folderView->setupFolderselect(&sels); | 572 | folderView->setupFolderselect(&sels); |
575 | if (!sels.exec()) return; | 573 | if (!sels.exec()) return; |
576 | targetMail = sels.currentMail(); | 574 | targetMail = sels.currentMail(); |
577 | targetFolder = sels.currentFolder(); | 575 | targetFolder = sels.currentFolder(); |
578 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 576 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
579 | targetFolder.isEmpty()) | 577 | targetFolder.isEmpty()) |
580 | { | 578 | { |
581 | return; | 579 | return; |
582 | } | 580 | } |
583 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 581 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
584 | { | 582 | { |
585 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 583 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
586 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 584 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
587 | return; | 585 | return; |
588 | } | 586 | } |
589 | sels.hide(); | 587 | sels.hide(); |
590 | qApp->processEvents(); | 588 | qApp->processEvents(); |
591 | // qDebug("hiding sels "); | 589 | // qDebug("hiding sels "); |
592 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 590 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
593 | folderView->refreshCurrent(); | 591 | folderView->refreshCurrent(); |
594 | } | 592 | } |
595 | 593 | ||
596 | void OpieMail::slotMoveCopyAllMail() | 594 | void OpieMail::slotMoveCopyAllMail() |
597 | { | 595 | { |
598 | 596 | ||
599 | if (!mailView->currentItem()) return; | 597 | if (!mailView->currentItem()) return; |
600 | QValueList<RecMailP> t; | 598 | QValueList<RecMailP> t; |
601 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 599 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
602 | { | 600 | { |
603 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 601 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
604 | while ( item ) { | 602 | while ( item ) { |
605 | if ( item->isSelected() ) { | 603 | if ( item->isSelected() ) { |
606 | t.append( item->data() ); | 604 | t.append( item->data() ); |
607 | } | 605 | } |
608 | item = (MailListViewItem*)item->nextSibling(); | 606 | item = (MailListViewItem*)item->nextSibling(); |
609 | } | 607 | } |
610 | } | 608 | } |
611 | // else | 609 | // else |
612 | // return; | 610 | // return; |
613 | if ( t.count() == 0 ) | 611 | if ( t.count() == 0 ) |
614 | return; | 612 | return; |
615 | RecMailP mail = t.first(); | 613 | RecMailP mail = t.first(); |
616 | AbstractMail*targetMail = 0; | 614 | AbstractMail*targetMail = 0; |
617 | QString targetFolder = ""; | 615 | QString targetFolder = ""; |
618 | Selectstore sels; | 616 | Selectstore sels; |
619 | folderView->setupFolderselect(&sels); | 617 | folderView->setupFolderselect(&sels); |
620 | if (!sels.exec()) return; | 618 | if (!sels.exec()) return; |
621 | targetMail = sels.currentMail(); | 619 | targetMail = sels.currentMail(); |
622 | targetFolder = sels.currentFolder(); | 620 | targetFolder = sels.currentFolder(); |
623 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 621 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
624 | targetFolder.isEmpty()) | 622 | targetFolder.isEmpty()) |
625 | { | 623 | { |
626 | return; | 624 | return; |
627 | } | 625 | } |
628 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 626 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
629 | { | 627 | { |
630 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 628 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
631 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 629 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
632 | return; | 630 | return; |
633 | } | 631 | } |
634 | sels.hide(); | 632 | sels.hide(); |
635 | qApp->processEvents(); | 633 | qApp->processEvents(); |
636 | //qDebug("hiding sels "); | 634 | //qDebug("hiding sels "); |
637 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); | 635 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); |
638 | folderView->refreshCurrent(); | 636 | folderView->refreshCurrent(); |
639 | } | 637 | } |
640 | 638 | ||
641 | void OpieMail::reEditMail() | 639 | void OpieMail::reEditMail() |
642 | { | 640 | { |
643 | if (!mailView->currentItem()) return; | 641 | if (!mailView->currentItem()) return; |
644 | 642 | ||
645 | ComposeMail compose( settings, this, 0, true ); | 643 | ComposeMail compose( settings, this, 0, true ); |
646 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); | 644 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); |
647 | compose.slotAdjustColumns(); | 645 | compose.slotAdjustColumns(); |
648 | #ifndef DESKTOP_VERSION | 646 | #ifndef DESKTOP_VERSION |
649 | compose.showMaximized(); | 647 | compose.showMaximized(); |
650 | #else | 648 | #else |
651 | compose.resize(640,480); | 649 | compose.resize(640,480); |
652 | #endif | 650 | #endif |
653 | mCurrentComposer = &compose; | 651 | mCurrentComposer = &compose; |
654 | compose.exec(); | 652 | compose.exec(); |
655 | folderView->refreshOutgoing(); | 653 | folderView->refreshOutgoing(); |
656 | mCurrentComposer = 0; | 654 | mCurrentComposer = 0; |
657 | } | 655 | } |
658 | 656 | ||
659 | void OpieMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 657 | void OpieMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
660 | { | 658 | { |
661 | 659 | ||
662 | if ( mCurrentComposer ) { | 660 | if ( mCurrentComposer ) { |
663 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); | 661 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); |
664 | } else { | 662 | } else { |
665 | ComposeMail compose( settings, this, 0, true ); | 663 | ComposeMail compose( settings, this, 0, true ); |
666 | compose.slotAdjustColumns(); | 664 | compose.slotAdjustColumns(); |
667 | #ifndef DESKTOP_VERSION | 665 | #ifndef DESKTOP_VERSION |
668 | compose.showMaximized(); | 666 | compose.showMaximized(); |
669 | #endif | 667 | #endif |
670 | mCurrentComposer = &compose; | 668 | mCurrentComposer = &compose; |
671 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); | 669 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); |
672 | compose.exec(); | 670 | compose.exec(); |
673 | mCurrentComposer = 0; | 671 | mCurrentComposer = 0; |
674 | folderView->refreshOutgoing(); | 672 | folderView->refreshOutgoing(); |
675 | raise(); | 673 | raise(); |
676 | } | 674 | } |
677 | } | 675 | } |