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