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