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