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