summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp16
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,542 +1,544 @@
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
39OpieMail::OpieMail( QWidget *parent, const char *name ) 40OpieMail::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
49OpieMail::~OpieMail() 50OpieMail::~OpieMail()
50{ 51{
51 if (settings) delete settings; 52 if (settings) delete settings;
52} 53}
53 54
54void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 55void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
55{ 56{
56 57
57} 58}
58#include <stdlib.h> 59#include <stdlib.h>
59void OpieMail::message(const QCString &msg, const QByteArray &data) 60void 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}
104void OpieMail::slotExtAppHandler() 105void OpieMail::slotExtAppHandler()
105{ 106{
106 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); 107 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData );
107} 108}
108void OpieMail::slotwriteMail2(const QString& namemail ) 109void 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
132 compose.exec(); 133 compose.exec();
133 raise(); 134 raise();
134 //qDebug("retttich "); 135 //qDebug("retttich ");
135} 136}
136void OpieMail::slotwriteMail(const QString&name,const QString&email) 137void OpieMail::slotwriteMail(const QString&name,const QString&email)
137{ 138{
138 // qDebug("OpieMail::slotwriteMail "); 139 // qDebug("OpieMail::slotwriteMail ");
139 ComposeMail compose( settings, this, 0, true ); 140 ComposeMail compose( settings, this, 0, true );
140 if (!email.isEmpty()) 141 if (!email.isEmpty())
141 { 142 {
142 if (!name.isEmpty()) 143 if (!name.isEmpty())
143 { 144 {
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
159void OpieMail::slotComposeMail() 160void 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
172void OpieMail::slotSendQueued() 173void 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
226void OpieMail::slotSearchMails() 227void OpieMail::slotSearchMails()
227{ 228{
228 qDebug("OpieMail::slotSearchMails():not implemented "); 229 qDebug("OpieMail::slotSearchMails():not implemented ");
229} 230}
230 231
231void OpieMail::slotEditSettings() 232void 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
243void OpieMail::slotEditAccounts() 245void 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}
256void OpieMail::replyMail() 258void 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}
300void OpieMail::displayMail() 302void 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}
325void OpieMail::slotGetAllMail() 327void 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}
333void OpieMail::slotGetMail() 335void 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}
339void OpieMail::slotDeleteMail() 341void 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}
349void OpieMail::slotDeleteAllMail() 351void 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}
373void OpieMail::clearSelection() 375void OpieMail::clearSelection()
374{ 376{
375 mailView->clearSelection(); 377 mailView->clearSelection();
376 378
377} 379}
378 380
379void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 381void 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)
388 { 390 {
389 if (mailtype==MAILLIB::A_NNTP) { 391 if (mailtype==MAILLIB::A_NNTP) {
390 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); 392 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail()));
391 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); 393 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail()));
392 m->insertSeparator(); 394 m->insertSeparator();
393 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); 395 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail()));
394 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 396 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
395 } else { 397 } else {
396 if (folderView->currentisDraft()) { 398 if (folderView->currentisDraft()) {
397 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); 399 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail()));
398 } 400 }
399 m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); 401 m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail()));
400 m->insertSeparator(); 402 m->insertSeparator();
401 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); 403 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail()));
402 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); 404 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
403 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); 405 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail()));
404 m->insertSeparator(); 406 m->insertSeparator();
405 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); 407 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
406 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 408 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
407 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 409 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
408 } 410 }
409 m->setFocus(); 411 m->setFocus();
410 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 412 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
411 delete m; 413 delete m;
412 } 414 }
413} 415}
414 416
415void OpieMail::slotShowFolders( bool show ) 417void OpieMail::slotShowFolders( bool show )
416{ 418{
417 if ( show && folderView->isHidden() ) 419 if ( show && folderView->isHidden() )
418 { 420 {
419 folderView->show(); 421 folderView->show();
420 } 422 }
421 else if ( !show && !folderView->isHidden() ) 423 else if ( !show && !folderView->isHidden() )
422 { 424 {
423 folderView->hide(); 425 folderView->hide();
424 } 426 }
425} 427}
426 428
427void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 429void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
428{ 430{
429 MailListViewItem*item = 0; 431 MailListViewItem*item = 0;
430 mailView->clear(); 432 mailView->clear();
431 433
432 QValueList<RecMailP>::ConstIterator it; 434 QValueList<RecMailP>::ConstIterator it;
433 for (it = list.begin(); it != list.end();++it) 435 for (it = list.begin(); it != list.end();++it)
434 { 436 {
435 item = new MailListViewItem(mailView,item); 437 item = new MailListViewItem(mailView,item);
436 item->storeData((*it)); 438 item->storeData((*it));
437 item->showEntry(); 439 item->showEntry();
438 } 440 }
439 mailView->setSorting ( 4, false ); 441 mailView->setSorting ( 4, false );
440} 442}
441 443
442void OpieMail::mailLeftClicked( QListViewItem *item ) 444void OpieMail::mailLeftClicked( QListViewItem *item )
443{ 445{
444 mailView->clearSelection(); 446 mailView->clearSelection();
445 /* just LEFT button - or tap with stylus on pda */ 447 /* just LEFT button - or tap with stylus on pda */
446 //if (button!=1) return; 448 //if (button!=1) return;
447 if (!item) return; 449 if (!item) return;
448 if (folderView->currentisDraft()) { 450 if (folderView->currentisDraft()) {
449 reEditMail(); 451 reEditMail();
450 } else { 452 } else {
451 displayMail(); 453 displayMail();
452 } 454 }
453} 455}
454 456
455void OpieMail::slotMoveCopyMail() 457void OpieMail::slotMoveCopyMail()
456{ 458{
457 if (!mailView->currentItem()) return; 459 if (!mailView->currentItem()) return;
458 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 460 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
459 AbstractMail*targetMail = 0; 461 AbstractMail*targetMail = 0;
460 QString targetFolder = ""; 462 QString targetFolder = "";
461 Selectstore sels; 463 Selectstore sels;
462 folderView->setupFolderselect(&sels); 464 folderView->setupFolderselect(&sels);
463 if (!sels.exec()) return; 465 if (!sels.exec()) return;
464 targetMail = sels.currentMail(); 466 targetMail = sels.currentMail();
465 targetFolder = sels.currentFolder(); 467 targetFolder = sels.currentFolder();
466 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 468 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
467 targetFolder.isEmpty()) 469 targetFolder.isEmpty())
468 { 470 {
469 return; 471 return;
470 } 472 }
471 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 473 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
472 { 474 {
473 QMessageBox::critical(0,i18n("Error creating new Folder"), 475 QMessageBox::critical(0,i18n("Error creating new Folder"),
474 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 476 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
475 return; 477 return;
476 } 478 }
477 sels.hide(); 479 sels.hide();
478 qApp->processEvents(); 480 qApp->processEvents();
479 // qDebug("hiding sels "); 481 // qDebug("hiding sels ");
480 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 482 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
481 folderView->refreshCurrent(); 483 folderView->refreshCurrent();
482} 484}
483 485
484void OpieMail::slotMoveCopyAllMail() 486void OpieMail::slotMoveCopyAllMail()
485{ 487{
486 488
487 if (!mailView->currentItem()) return; 489 if (!mailView->currentItem()) return;
488 QValueList<RecMailP> t; 490 QValueList<RecMailP> t;
489 // 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 ) 491 // 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 )
490 { 492 {
491 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 493 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
492 while ( item ) { 494 while ( item ) {
493 if ( item->isSelected() ) { 495 if ( item->isSelected() ) {
494 t.append( item->data() ); 496 t.append( item->data() );
495 } 497 }
496 item = (MailListViewItem*)item->nextSibling(); 498 item = (MailListViewItem*)item->nextSibling();
497 } 499 }
498 } 500 }
499 // else 501 // else
500 // return; 502 // return;
501 if ( t.count() == 0 ) 503 if ( t.count() == 0 )
502 return; 504 return;
503 RecMailP mail = t.first(); 505 RecMailP mail = t.first();
504 AbstractMail*targetMail = 0; 506 AbstractMail*targetMail = 0;
505 QString targetFolder = ""; 507 QString targetFolder = "";
506 Selectstore sels; 508 Selectstore sels;
507 folderView->setupFolderselect(&sels); 509 folderView->setupFolderselect(&sels);
508 if (!sels.exec()) return; 510 if (!sels.exec()) return;
509 targetMail = sels.currentMail(); 511 targetMail = sels.currentMail();
510 targetFolder = sels.currentFolder(); 512 targetFolder = sels.currentFolder();
511 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 513 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
512 targetFolder.isEmpty()) 514 targetFolder.isEmpty())
513 { 515 {
514 return; 516 return;
515 } 517 }
516 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 518 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
517 { 519 {
518 QMessageBox::critical(0,i18n("Error creating new Folder"), 520 QMessageBox::critical(0,i18n("Error creating new Folder"),
519 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 521 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
520 return; 522 return;
521 } 523 }
522 sels.hide(); 524 sels.hide();
523 qApp->processEvents(); 525 qApp->processEvents();
524 //qDebug("hiding sels "); 526 //qDebug("hiding sels ");
525 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); 527 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
526 folderView->refreshCurrent(); 528 folderView->refreshCurrent();
527} 529}
528 530
529void OpieMail::reEditMail() 531void OpieMail::reEditMail()
530{ 532{
531 if (!mailView->currentItem()) return; 533 if (!mailView->currentItem()) return;
532 534
533 ComposeMail compose( settings, this, 0, true ); 535 ComposeMail compose( settings, this, 0, true );
534 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 536 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
535 compose.slotAdjustColumns(); 537 compose.slotAdjustColumns();
536#ifndef DESKTOP_VERSION 538#ifndef DESKTOP_VERSION
537 compose.showMaximized(); 539 compose.showMaximized();
538#else 540#else
539 compose.resize(640,480); 541 compose.resize(640,480);
540#endif 542#endif
541 compose.exec(); 543 compose.exec();
542} 544}