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