-rw-r--r-- | kmicromail/opiemail.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index af5376f..18a5600 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,131 +1,132 @@ | |||
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 | #include "koprefsdialog.h" | 4 | #include "koprefsdialog.h" |
5 | #include <kapplication.h> | 5 | #include <kapplication.h> |
6 | #include <libkdepim/externalapphandler.h> | 6 | #include <libkdepim/externalapphandler.h> |
7 | #include <libkdepim/kpimglobalprefs.h> | 7 | #include <libkdepim/kpimglobalprefs.h> |
8 | #ifdef MINIKDE_KDIALOG_H | 8 | #ifdef MINIKDE_KDIALOG_H |
9 | #undef MINIKDE_KDIALOG_H | 9 | #undef MINIKDE_KDIALOG_H |
10 | #endif | 10 | #endif |
11 | #include "settingsdialog.h" | 11 | #include "settingsdialog.h" |
12 | #include "opiemail.h" | 12 | #include "opiemail.h" |
13 | #include "editaccounts.h" | 13 | #include "editaccounts.h" |
14 | #include "composemail.h" | 14 | #include "composemail.h" |
15 | #include "mailistviewitem.h" | 15 | #include "mailistviewitem.h" |
16 | #include "viewmail.h" | 16 | #include "viewmail.h" |
17 | #include "selectstore.h" | 17 | #include "selectstore.h" |
18 | #include "selectsmtp.h" | 18 | #include "selectsmtp.h" |
19 | #include "accountitem.h" | 19 | #include "accountitem.h" |
20 | #include "klocale.h" | 20 | #include "klocale.h" |
21 | 21 | ||
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qcursor.h> | 24 | #include <qcursor.h> |
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | #include <qpe/global.h> | 26 | #include <qpe/global.h> |
27 | 27 | ||
28 | #ifdef DESKTOP_VERSION | 28 | #ifdef DESKTOP_VERSION |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | #else | 30 | #else |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #endif | 32 | #endif |
33 | #include <libmailwrapper/smtpwrapper.h> | 33 | #include <libmailwrapper/smtpwrapper.h> |
34 | #include <libmailwrapper/mailtypes.h> | 34 | #include <libmailwrapper/mailtypes.h> |
35 | #include <libmailwrapper/abstractmail.h> | 35 | #include <libmailwrapper/abstractmail.h> |
36 | #include "koprefs.h" | ||
36 | 37 | ||
37 | //using namespace Opie::Core; | 38 | //using namespace Opie::Core; |
38 | 39 | ||
39 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 40 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
40 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 41 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
41 | { | 42 | { |
42 | settings = new Settings(); | 43 | settings = new Settings(); |
43 | 44 | ||
44 | setIcon(SmallIcon( "kmicromail" ) ); | 45 | setIcon(SmallIcon( "kmicromail" ) ); |
45 | folderView->populate( settings->getAccounts() ); | 46 | folderView->populate( settings->getAccounts() ); |
46 | 47 | ||
47 | } | 48 | } |
48 | 49 | ||
49 | OpieMail::~OpieMail() | 50 | OpieMail::~OpieMail() |
50 | { | 51 | { |
51 | if (settings) delete settings; | 52 | if (settings) delete settings; |
52 | } | 53 | } |
53 | 54 | ||
54 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 55 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
55 | { | 56 | { |
56 | 57 | ||
57 | } | 58 | } |
58 | #include <stdlib.h> | 59 | #include <stdlib.h> |
59 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 60 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
60 | { | 61 | { |
61 | // copied from old mail2 | 62 | // copied from old mail2 |
62 | static int ii = 0; | 63 | static int ii = 0; |
63 | //qDebug("QCOP CALL ############################# %d ", ii); | 64 | //qDebug("QCOP CALL ############################# %d ", ii); |
64 | //QString mess ( msg ); | 65 | //QString mess ( msg ); |
65 | //qDebug("Message = %s ",mess.latin1()); | 66 | //qDebug("Message = %s ",mess.latin1()); |
66 | ++ii; | 67 | ++ii; |
67 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 68 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
68 | 69 | ||
69 | mPendingEmail = QString::null; | 70 | mPendingEmail = QString::null; |
70 | mPendingName = QString::null; | 71 | mPendingName = QString::null; |
71 | if (msg == "writeMail(QString,QString)") | 72 | if (msg == "writeMail(QString,QString)") |
72 | { | 73 | { |
73 | //qDebug("writeMail(QString,QString) "); | 74 | //qDebug("writeMail(QString,QString) "); |
74 | QDataStream stream(data,IO_ReadOnly); | 75 | QDataStream stream(data,IO_ReadOnly); |
75 | stream >> mPendingName >> mPendingEmail; | 76 | stream >> mPendingName >> mPendingEmail; |
76 | // removing the whitespaces at beginning and end is needed! | 77 | // removing the whitespaces at beginning and end is needed! |
77 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 78 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
78 | } | 79 | } |
79 | else if (msg == "newMail()") | 80 | else if (msg == "newMail()") |
80 | { | 81 | { |
81 | //qDebug("slotComposeMail() "); | 82 | //qDebug("slotComposeMail() "); |
82 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 83 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
83 | // and a QCOP call does not like a processevents in his execution | 84 | // and a QCOP call does not like a processevents in his execution |
84 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 85 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
85 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 86 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
86 | // slotComposeMail(); | 87 | // slotComposeMail(); |
87 | } | 88 | } |
88 | else if (msg == "newMail(QString)") | 89 | else if (msg == "newMail(QString)") |
89 | { | 90 | { |
90 | //qDebug(" newMail(QString)"); | 91 | //qDebug(" newMail(QString)"); |
91 | QDataStream stream(data,IO_ReadOnly); | 92 | QDataStream stream(data,IO_ReadOnly); |
92 | stream >> mPendingName; | 93 | stream >> mPendingName; |
93 | // the format is | 94 | // the format is |
94 | // NAME <EMAIL>:SUBJECT | 95 | // NAME <EMAIL>:SUBJECT |
95 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
96 | } else { | 97 | } else { |
97 | mPendingData = data; | 98 | mPendingData = data; |
98 | mPendingMessage = msg; | 99 | mPendingMessage = msg; |
99 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 100 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
100 | } | 101 | } |
101 | 102 | ||
102 | //qDebug("END OpieMail::message "); | 103 | //qDebug("END OpieMail::message "); |
103 | } | 104 | } |
104 | void OpieMail::slotExtAppHandler() | 105 | void OpieMail::slotExtAppHandler() |
105 | { | 106 | { |
106 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 107 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
107 | } | 108 | } |
108 | void OpieMail::slotwriteMail2(const QString& namemail ) | 109 | void OpieMail::slotwriteMail2(const QString& namemail ) |
109 | { | 110 | { |
110 | //qDebug("OpieMail::slotwriteMail2 "); | 111 | //qDebug("OpieMail::slotwriteMail2 "); |
111 | //qApp->processEvents(); | 112 | //qApp->processEvents(); |
112 | ComposeMail compose( settings, this, 0, true ); | 113 | ComposeMail compose( settings, this, 0, true ); |
113 | if ( !namemail.isEmpty() ) { | 114 | if ( !namemail.isEmpty() ) { |
114 | QString to = namemail; | 115 | QString to = namemail; |
115 | if ( namemail.find( " <") > 1 ) { | 116 | if ( namemail.find( " <") > 1 ) { |
116 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 117 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
117 | } else | 118 | } else |
118 | if ( namemail.find( "<") > 1 ) { | 119 | if ( namemail.find( "<") > 1 ) { |
119 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 120 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
120 | } | 121 | } |
121 | int sub = to.find( ">:"); | 122 | int sub = to.find( ">:"); |
122 | if ( sub > 0 ) { | 123 | if ( sub > 0 ) { |
123 | compose.setTo( to.left(sub+1) ); | 124 | compose.setTo( to.left(sub+1) ); |
124 | compose.setSubject( to.mid(sub+2) ); | 125 | compose.setSubject( to.mid(sub+2) ); |
125 | } else | 126 | } else |
126 | compose.setTo( to ); | 127 | compose.setTo( to ); |
127 | } | 128 | } |
128 | compose.slotAdjustColumns(); | 129 | compose.slotAdjustColumns(); |
129 | #ifndef DESKTOP_VERSION | 130 | #ifndef DESKTOP_VERSION |
130 | compose.showMaximized(); | 131 | compose.showMaximized(); |
131 | #endif | 132 | #endif |
@@ -144,244 +145,245 @@ void OpieMail::slotwriteMail(const QString&name,const QString&email) | |||
144 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 145 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
145 | } | 146 | } |
146 | else | 147 | else |
147 | { | 148 | { |
148 | compose.setTo(email); | 149 | compose.setTo(email); |
149 | } | 150 | } |
150 | } | 151 | } |
151 | compose.slotAdjustColumns(); | 152 | compose.slotAdjustColumns(); |
152 | #ifndef DESKTOP_VERSION | 153 | #ifndef DESKTOP_VERSION |
153 | compose.showMaximized(); | 154 | compose.showMaximized(); |
154 | #endif | 155 | #endif |
155 | compose.exec(); | 156 | compose.exec(); |
156 | raise(); | 157 | raise(); |
157 | } | 158 | } |
158 | 159 | ||
159 | void OpieMail::slotComposeMail() | 160 | void OpieMail::slotComposeMail() |
160 | { | 161 | { |
161 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 162 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
162 | slotwriteMail2( QString () ); | 163 | slotwriteMail2( QString () ); |
163 | else { | 164 | else { |
164 | if ( mPendingEmail == QString::null ) | 165 | if ( mPendingEmail == QString::null ) |
165 | slotwriteMail2( mPendingName ); | 166 | slotwriteMail2( mPendingName ); |
166 | else | 167 | else |
167 | slotwriteMail( mPendingName, mPendingEmail ); | 168 | slotwriteMail( mPendingName, mPendingEmail ); |
168 | } | 169 | } |
169 | //slotwriteMail(0l,0l); | 170 | //slotwriteMail(0l,0l); |
170 | } | 171 | } |
171 | 172 | ||
172 | void OpieMail::slotSendQueued() | 173 | void OpieMail::slotSendQueued() |
173 | { | 174 | { |
174 | SMTPaccount *smtp = 0; | 175 | SMTPaccount *smtp = 0; |
175 | 176 | ||
176 | QList<Account> list = settings->getAccounts(); | 177 | QList<Account> list = settings->getAccounts(); |
177 | QList<SMTPaccount> smtpList; | 178 | QList<SMTPaccount> smtpList; |
178 | smtpList.setAutoDelete(false); | 179 | smtpList.setAutoDelete(false); |
179 | Account *it; | 180 | Account *it; |
180 | for ( it = list.first(); it; it = list.next() ) | 181 | for ( it = list.first(); it; it = list.next() ) |
181 | { | 182 | { |
182 | if ( it->getType() == MAILLIB::A_SMTP ) | 183 | if ( it->getType() == MAILLIB::A_SMTP ) |
183 | { | 184 | { |
184 | smtp = static_cast<SMTPaccount *>(it); | 185 | smtp = static_cast<SMTPaccount *>(it); |
185 | smtpList.append(smtp); | 186 | smtpList.append(smtp); |
186 | } | 187 | } |
187 | } | 188 | } |
188 | if (smtpList.count()==0) | 189 | if (smtpList.count()==0) |
189 | { | 190 | { |
190 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 191 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); |
191 | return; | 192 | return; |
192 | } | 193 | } |
193 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 194 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
194 | return; | 195 | return; |
195 | if (smtpList.count()==1) | 196 | if (smtpList.count()==1) |
196 | { | 197 | { |
197 | smtp = smtpList.at(0); | 198 | smtp = smtpList.at(0); |
198 | } | 199 | } |
199 | else | 200 | else |
200 | { | 201 | { |
201 | smtp = 0; | 202 | smtp = 0; |
202 | selectsmtp selsmtp; | 203 | selectsmtp selsmtp; |
203 | selsmtp.setSelectionlist(&smtpList); | 204 | selsmtp.setSelectionlist(&smtpList); |
204 | #ifndef DESKTOP_VERSION | 205 | #ifndef DESKTOP_VERSION |
205 | selsmtp.showMaximized(); | 206 | selsmtp.showMaximized(); |
206 | #endif | 207 | #endif |
207 | if ( selsmtp.exec() == QDialog::Accepted ) | 208 | if ( selsmtp.exec() == QDialog::Accepted ) |
208 | { | 209 | { |
209 | smtp = selsmtp.selected_smtp(); | 210 | smtp = selsmtp.selected_smtp(); |
210 | } | 211 | } |
211 | } | 212 | } |
212 | if (smtp) | 213 | if (smtp) |
213 | { | 214 | { |
214 | 215 | ||
215 | Global::statusMessage("Sending mails...!"); | 216 | Global::statusMessage("Sending mails...!"); |
216 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 217 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
217 | if ( wrap->flushOutbox() ) | 218 | if ( wrap->flushOutbox() ) |
218 | { | 219 | { |
219 | Global::statusMessage("Mails sent!"); | 220 | Global::statusMessage("Mails sent!"); |
220 | } | 221 | } |
221 | delete wrap; | 222 | delete wrap; |
222 | } | 223 | } |
223 | // pending refresh list view, if outgoing is displayed | 224 | // pending refresh list view, if outgoing is displayed |
224 | } | 225 | } |
225 | 226 | ||
226 | void OpieMail::slotSearchMails() | 227 | void OpieMail::slotSearchMails() |
227 | { | 228 | { |
228 | qDebug("OpieMail::slotSearchMails():not implemented "); | 229 | qDebug("OpieMail::slotSearchMails():not implemented "); |
229 | } | 230 | } |
230 | 231 | ||
231 | void OpieMail::slotEditSettings() | 232 | void OpieMail::slotEditSettings() |
232 | { | 233 | { |
233 | 234 | ||
234 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 235 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
235 | #ifndef DESKTOP_VERSION | 236 | #ifndef DESKTOP_VERSION |
236 | settingsDialog.showMaximized(); | 237 | settingsDialog.showMaximized(); |
237 | #endif | 238 | #endif |
238 | settingsDialog.exec(); | 239 | settingsDialog.exec(); |
239 | 240 | ||
241 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | ||
240 | // KApplication::execDialog(settingsDialog); | 242 | // KApplication::execDialog(settingsDialog); |
241 | } | 243 | } |
242 | 244 | ||
243 | void OpieMail::slotEditAccounts() | 245 | void OpieMail::slotEditAccounts() |
244 | { | 246 | { |
245 | EditAccounts eaDialog( settings, this, 0, true ); | 247 | EditAccounts eaDialog( settings, this, 0, true ); |
246 | eaDialog.slotAdjustColumns(); | 248 | eaDialog.slotAdjustColumns(); |
247 | #ifndef DESKTOP_VERSION | 249 | #ifndef DESKTOP_VERSION |
248 | eaDialog.showMaximized(); | 250 | eaDialog.showMaximized(); |
249 | #endif | 251 | #endif |
250 | eaDialog.exec(); | 252 | eaDialog.exec(); |
251 | if ( settings ) delete settings; | 253 | if ( settings ) delete settings; |
252 | settings = new Settings(); | 254 | settings = new Settings(); |
253 | 255 | ||
254 | folderView->populate( settings->getAccounts() ); | 256 | folderView->populate( settings->getAccounts() ); |
255 | } | 257 | } |
256 | void OpieMail::replyMail() | 258 | void OpieMail::replyMail() |
257 | { | 259 | { |
258 | 260 | ||
259 | QListViewItem*item = mailView->currentItem(); | 261 | QListViewItem*item = mailView->currentItem(); |
260 | if (!item) return; | 262 | if (!item) return; |
261 | RecMailP mail = ((MailListViewItem*)item)->data(); | 263 | RecMailP mail = ((MailListViewItem*)item)->data(); |
262 | RecBodyP body = folderView->fetchBody(mail); | 264 | RecBodyP body = folderView->fetchBody(mail); |
263 | 265 | ||
264 | QString rtext; | 266 | QString rtext; |
265 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 267 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
266 | .arg( QString::fromUtf8( mail->getFrom().latin1())) | 268 | .arg( mail->getFrom()) |
267 | .arg( QString::fromUtf8( mail->getDate().latin1() )); | 269 | .arg( mail->getDate()); |
268 | 270 | ||
269 | QString text = QString::fromUtf8( body->Bodytext().latin1() ); | 271 | QString text = body->Bodytext(); |
270 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 272 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
271 | QStringList::Iterator it; | 273 | QStringList::Iterator it; |
272 | for (it = lines.begin(); it != lines.end(); it++) | 274 | for (it = lines.begin(); it != lines.end(); it++) |
273 | { | 275 | { |
274 | rtext += "> " + *it + "\n"; | 276 | rtext += "> " + *it + "\n"; |
275 | } | 277 | } |
276 | rtext += "\n"; | 278 | rtext += "\n"; |
277 | 279 | ||
278 | QString prefix; | 280 | QString prefix; |
279 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 281 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
280 | else prefix = "Re: "; // no i18n on purpose | 282 | else prefix = "Re: "; // no i18n on purpose |
281 | 283 | ||
282 | Settings *settings = new Settings(); | 284 | Settings *settings = new Settings(); |
283 | ComposeMail composer( settings ,this, 0, true); | 285 | ComposeMail composer( settings ,this, 0, true); |
284 | if (mail->Replyto().isEmpty()) { | 286 | if (mail->Replyto().isEmpty()) { |
285 | composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); | 287 | composer.setTo( mail->getFrom()); |
286 | } else { | 288 | } else { |
287 | composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); | 289 | composer.setTo( mail->Replyto()); |
288 | } | 290 | } |
289 | composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) ); | 291 | composer.setSubject( prefix + mail->getSubject()); |
290 | composer.setMessage( rtext ); | 292 | composer.setMessage( rtext ); |
291 | composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1())); | 293 | composer.setInReplyTo( mail->Msgid()); |
292 | 294 | ||
293 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 295 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
294 | { | 296 | { |
295 | mail->Wrapper()->answeredMail(mail); | 297 | mail->Wrapper()->answeredMail(mail); |
296 | } | 298 | } |
297 | delete settings; | 299 | delete settings; |
298 | 300 | ||
299 | } | 301 | } |
300 | void OpieMail::displayMail() | 302 | void OpieMail::displayMail() |
301 | { | 303 | { |
302 | QListViewItem*item = mailView->currentItem(); | 304 | QListViewItem*item = mailView->currentItem(); |
303 | if (!item) return; | 305 | if (!item) return; |
304 | RecMailP mail = ((MailListViewItem*)item)->data(); | 306 | RecMailP mail = ((MailListViewItem*)item)->data(); |
305 | RecBodyP body = folderView->fetchBody(mail); | 307 | RecBodyP body = folderView->fetchBody(mail); |
306 | ViewMail readMail( this,"", Qt::WType_Modal ); | 308 | ViewMail readMail( this,"", Qt::WType_Modal ); |
307 | readMail.setBody( body ); | 309 | readMail.setBody( body ); |
308 | readMail.setMail( mail ); | 310 | readMail.setMail( mail ); |
309 | #ifndef DESKTOP_VERSION | 311 | #ifndef DESKTOP_VERSION |
310 | readMail.showMaximized(); | 312 | readMail.showMaximized(); |
311 | #else | 313 | #else |
312 | readMail.resize( 640, 480); | 314 | readMail.resize( 640, 480); |
313 | #endif | 315 | #endif |
314 | readMail.exec(); | 316 | readMail.exec(); |
315 | 317 | ||
316 | if ( readMail.deleted ) | 318 | if ( readMail.deleted ) |
317 | { | 319 | { |
318 | folderView->refreshCurrent(); | 320 | folderView->refreshCurrent(); |
319 | } | 321 | } |
320 | else | 322 | else |
321 | { | 323 | { |
322 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 324 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
323 | } | 325 | } |
324 | } | 326 | } |
325 | void OpieMail::slotGetAllMail() | 327 | void OpieMail::slotGetAllMail() |
326 | { | 328 | { |
327 | QListViewItem * item = folderView->firstChild(); | 329 | QListViewItem * item = folderView->firstChild(); |
328 | while ( item ){ | 330 | while ( item ){ |
329 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 331 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
330 | item = item->nextSibling (); | 332 | item = item->nextSibling (); |
331 | } | 333 | } |
332 | } | 334 | } |
333 | void OpieMail::slotGetMail() | 335 | void OpieMail::slotGetMail() |
334 | { | 336 | { |
335 | QListViewItem * item = folderView->currentItem(); | 337 | QListViewItem * item = folderView->currentItem(); |
336 | if ( ! item ) return; | 338 | if ( ! item ) return; |
337 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 339 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
338 | } | 340 | } |
339 | void OpieMail::slotDeleteMail() | 341 | void OpieMail::slotDeleteMail() |
340 | { | 342 | { |
341 | if (!mailView->currentItem()) return; | 343 | if (!mailView->currentItem()) return; |
342 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 344 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
343 | 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 ) | 345 | 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 ) |
344 | { | 346 | { |
345 | mail->Wrapper()->deleteMail( mail ); | 347 | mail->Wrapper()->deleteMail( mail ); |
346 | folderView->refreshCurrent(); | 348 | folderView->refreshCurrent(); |
347 | } | 349 | } |
348 | } | 350 | } |
349 | void OpieMail::slotDeleteAllMail() | 351 | void OpieMail::slotDeleteAllMail() |
350 | { | 352 | { |
351 | 353 | ||
352 | QValueList<RecMailP> t; | 354 | QValueList<RecMailP> t; |
353 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 355 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
354 | { | 356 | { |
355 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 357 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
356 | while ( item ) { | 358 | while ( item ) { |
357 | if ( item->isSelected() ) { | 359 | if ( item->isSelected() ) { |
358 | t.append( item->data() ); | 360 | t.append( item->data() ); |
359 | } | 361 | } |
360 | item = (MailListViewItem*)item->nextSibling(); | 362 | item = (MailListViewItem*)item->nextSibling(); |
361 | } | 363 | } |
362 | } | 364 | } |
363 | else | 365 | else |
364 | return; | 366 | return; |
365 | if ( t.count() == 0 ) | 367 | if ( t.count() == 0 ) |
366 | return; | 368 | return; |
367 | RecMailP mail = t.first(); | 369 | RecMailP mail = t.first(); |
368 | mail->Wrapper()->deleteMailList(t); | 370 | mail->Wrapper()->deleteMailList(t); |
369 | folderView->refreshCurrent(); | 371 | folderView->refreshCurrent(); |
370 | 372 | ||
371 | 373 | ||
372 | } | 374 | } |
373 | void OpieMail::clearSelection() | 375 | void OpieMail::clearSelection() |
374 | { | 376 | { |
375 | mailView->clearSelection(); | 377 | mailView->clearSelection(); |
376 | 378 | ||
377 | } | 379 | } |
378 | 380 | ||
379 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 381 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
380 | { | 382 | { |
381 | if (!mailView->currentItem()) return; | 383 | if (!mailView->currentItem()) return; |
382 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 384 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
383 | /* just the RIGHT button - or hold on pda */ | 385 | /* just the RIGHT button - or hold on pda */ |
384 | if (button!=2) {return;} | 386 | if (button!=2) {return;} |
385 | if (!item) return; | 387 | if (!item) return; |
386 | QPopupMenu *m = new QPopupMenu(0); | 388 | QPopupMenu *m = new QPopupMenu(0); |
387 | if (m) | 389 | if (m) |