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