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