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