summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 3fbdcec..251f15a 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,45 +1,45 @@
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 12
13#include <qmessagebox.h> 13#include <qmessagebox.h>
14 14
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include <libmailwrapper/smtpwrapper.h> 16#include <libmailwrapper/smtpwrapper.h>
17#include <libmailwrapper/mailtypes.h> 17#include <libmailwrapper/mailtypes.h>
18#include <libmailwrapper/abstractmail.h> 18#include <libmailwrapper/abstractmail.h>
19/* OPIE */ 19/* OPIE */
20//#include <qpe/resource.h> 20//#include <qpe/resource.h>
21#include <qpe/qpeapplication.h> 21//#include <qpe/qpeapplication.h>
22 22
23/* QT */ 23/* QT */
24 24
25using namespace Opie::Core; 25using namespace Opie::Core;
26 26
27OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 27OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
28 : MainWindow( parent, name) //, WStyle_ContextHelp ) 28 : MainWindow( parent, name) //, WStyle_ContextHelp )
29{ 29{
30 settings = new Settings(); 30 settings = new Settings();
31 31
32 folderView->populate( settings->getAccounts() ); 32 folderView->populate( settings->getAccounts() );
33 33
34} 34}
35 35
36OpieMail::~OpieMail() 36OpieMail::~OpieMail()
37{ 37{
38 if (settings) delete settings; 38 if (settings) delete settings;
39} 39}
40 40
41void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 41void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
42{ 42{
43 43
44} 44}
45#include <stdlib.h> 45#include <stdlib.h>
@@ -216,91 +216,98 @@ void OpieMail::displayMail()
216 readMail.exec(); 216 readMail.exec();
217 217
218 if ( readMail.deleted ) 218 if ( readMail.deleted )
219 { 219 {
220 folderView->refreshCurrent(); 220 folderView->refreshCurrent();
221 } 221 }
222 else 222 else
223 { 223 {
224 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 224 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
225 } 225 }
226} 226}
227 227
228void OpieMail::slotDeleteMail() 228void OpieMail::slotDeleteMail()
229{ 229{
230 if (!mailView->currentItem()) return; 230 if (!mailView->currentItem()) return;
231 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 231 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
232 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 ) 232 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 )
233 { 233 {
234 mail->Wrapper()->deleteMail( mail ); 234 mail->Wrapper()->deleteMail( mail );
235 folderView->refreshCurrent(); 235 folderView->refreshCurrent();
236 } 236 }
237} 237}
238void OpieMail::slotDeleteAllMail() 238void OpieMail::slotDeleteAllMail()
239{ 239{
240 if (!mailView->currentItem()) return; 240
241 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 241 QValueList<RecMailP> t;
242 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 242 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
243 { 243 {
244 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 244 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
245 while ( item ) { 245 while ( item ) {
246 if ( item->isSelected() ) { 246 if ( item->isSelected() ) {
247 RecMailP mail = item->data(); 247 t.append( item->data() );
248 mail->Wrapper()->deleteMail( mail ); 248 }
249 item = (MailListViewItem*)item->nextSibling();
249 } 250 }
250 item = (MailListViewItem*)item->nextSibling();
251 } 251 }
252 folderView->refreshCurrent(); 252 else
253 } 253 return;
254 if ( t.count() == 0 )
255 return;
256 RecMailP mail = t.first();
257 mail->Wrapper()->deleteMailList(t);
258 folderView->refreshCurrent();
259
260
254} 261}
255void OpieMail::clearSelection() 262void OpieMail::clearSelection()
256{ 263{
257 mailView->clearSelection(); 264 mailView->clearSelection();
258 265
259} 266}
260 267
261void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 268void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
262{ 269{
263 if (!mailView->currentItem()) return; 270 if (!mailView->currentItem()) return;
264 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 271 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
265 /* just the RIGHT button - or hold on pda */ 272 /* just the RIGHT button - or hold on pda */
266 if (button!=2) {return;} 273 if (button!=2) {return;}
267 if (!item) return; 274 if (!item) return;
268 QPopupMenu *m = new QPopupMenu(0); 275 QPopupMenu *m = new QPopupMenu(0);
269 if (m) 276 if (m)
270 { 277 {
271 if (mailtype==MAILLIB::A_NNTP) { 278 if (mailtype==MAILLIB::A_NNTP) {
272 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 279 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
273// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 280// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
274 } else { 281 } else {
275 if (folderView->currentisDraft()) { 282 if (folderView->currentisDraft()) {
276 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); 283 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
277 } 284 }
278 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 285 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
279 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 286 m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
280 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 287 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
281 m->insertSeparator(); 288 m->insertSeparator();
282 m->insertItem(tr("Copy/Move all selected mail"),this,SLOT(slotMoveCopyAllMail())); 289 m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
283 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 290 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
284 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); 291 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection()));
285 } 292 }
286 m->setFocus(); 293 m->setFocus();
287 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 294 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
288 delete m; 295 delete m;
289 } 296 }
290} 297}
291 298
292void OpieMail::slotShowFolders( bool show ) 299void OpieMail::slotShowFolders( bool show )
293{ 300{
294 if ( show && folderView->isHidden() ) 301 if ( show && folderView->isHidden() )
295 { 302 {
296 folderView->show(); 303 folderView->show();
297 } 304 }
298 else if ( !show && !folderView->isHidden() ) 305 else if ( !show && !folderView->isHidden() )
299 { 306 {
300 folderView->hide(); 307 folderView->hide();
301 } 308 }
302} 309}
303 310
304void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 311void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
305{ 312{
306 MailListViewItem*item = 0; 313 MailListViewItem*item = 0;
@@ -329,80 +336,86 @@ void OpieMail::mailLeftClicked( QListViewItem *item )
329} 336}
330 337
331void OpieMail::slotMoveCopyMail() 338void OpieMail::slotMoveCopyMail()
332{ 339{
333 if (!mailView->currentItem()) return; 340 if (!mailView->currentItem()) return;
334 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 341 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
335 AbstractMail*targetMail = 0; 342 AbstractMail*targetMail = 0;
336 QString targetFolder = ""; 343 QString targetFolder = "";
337 Selectstore sels; 344 Selectstore sels;
338 folderView->setupFolderselect(&sels); 345 folderView->setupFolderselect(&sels);
339 if (!sels.exec()) return; 346 if (!sels.exec()) return;
340 targetMail = sels.currentMail(); 347 targetMail = sels.currentMail();
341 targetFolder = sels.currentFolder(); 348 targetFolder = sels.currentFolder();
342 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 349 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
343 targetFolder.isEmpty()) 350 targetFolder.isEmpty())
344 { 351 {
345 return; 352 return;
346 } 353 }
347 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 354 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
348 { 355 {
349 QMessageBox::critical(0,tr("Error creating new Folder"), 356 QMessageBox::critical(0,tr("Error creating new Folder"),
350 tr("<center>Error while creating<br>new folder - breaking.</center>")); 357 tr("<center>Error while creating<br>new folder - breaking.</center>"));
351 return; 358 return;
352 } 359 }
360 sels.hide();
361 qApp->processEvents();
362 // qDebug("hiding sels ");
353 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 363 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
354 folderView->refreshCurrent(); 364 folderView->refreshCurrent();
355} 365}
356 366
357void OpieMail::slotMoveCopyAllMail() 367void OpieMail::slotMoveCopyAllMail()
358{ 368{
359 369
360 if (!mailView->currentItem()) return; 370 if (!mailView->currentItem()) return;
361 QValueList<RecMailP> t; 371 QValueList<RecMailP> t;
362 if ( QMessageBox::warning(this, tr("Copy/Move all selected mails"), tr("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 372 // 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 )
363 { 373 {
364 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 374 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
365 while ( item ) { 375 while ( item ) {
366 if ( item->isSelected() ) { 376 if ( item->isSelected() ) {
367 t.append( item->data() ); 377 t.append( item->data() );
368 } 378 }
369 item = (MailListViewItem*)item->nextSibling(); 379 item = (MailListViewItem*)item->nextSibling();
370 } 380 }
371 } 381 }
372 else 382 // else
373 return; 383 // return;
374 if ( t.count() == 0 ) 384 if ( t.count() == 0 )
375 return; 385 return;
376 RecMailP mail = t.first(); 386 RecMailP mail = t.first();
377 AbstractMail*targetMail = 0; 387 AbstractMail*targetMail = 0;
378 QString targetFolder = ""; 388 QString targetFolder = "";
379 Selectstore sels; 389 Selectstore sels;
380 folderView->setupFolderselect(&sels); 390 folderView->setupFolderselect(&sels);
381 if (!sels.exec()) return; 391 if (!sels.exec()) return;
382 targetMail = sels.currentMail(); 392 targetMail = sels.currentMail();
383 targetFolder = sels.currentFolder(); 393 targetFolder = sels.currentFolder();
384 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 394 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
385 targetFolder.isEmpty()) 395 targetFolder.isEmpty())
386 { 396 {
387 return; 397 return;
388 } 398 }
389 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 399 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
390 { 400 {
391 QMessageBox::critical(0,tr("Error creating new Folder"), 401 QMessageBox::critical(0,tr("Error creating new Folder"),
392 tr("<center>Error while creating<br>new folder - breaking.</center>")); 402 tr("<center>Error while creating<br>new folder - breaking.</center>"));
393 return; 403 return;
394 } 404 }
405 sels.hide();
406 qApp->processEvents();
407 //qDebug("hiding sels ");
395 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); 408 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
396 folderView->refreshCurrent(); 409 folderView->refreshCurrent();
397} 410}
398 411
399void OpieMail::reEditMail() 412void OpieMail::reEditMail()
400{ 413{
401 if (!mailView->currentItem()) return; 414 if (!mailView->currentItem()) return;
402 415
403 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 416 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
404 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 417 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
405 compose.slotAdjustColumns(); 418 compose.slotAdjustColumns();
406 compose.showMaximized(); 419 compose.showMaximized();
407 compose.exec(); 420 compose.exec();
408} 421}