Diffstat (limited to 'noncore/net/mail/accountview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/accountview.cpp | 143 |
1 files changed, 126 insertions, 17 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 8aac14b..30765cf 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -185,10 +185,10 @@ QPopupMenu * IMAPviewItem::getContextMenu() | |||
185 | { | 185 | { |
186 | QPopupMenu *m = new QPopupMenu(0); | 186 | QPopupMenu *m = new QPopupMenu(0); |
187 | if (m) { | 187 | if (m) { |
188 | m->insertItem(QObject::tr("Refresh folder list","IMAPviewItem"),0); | 188 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
189 | m->insertItem(QObject::tr("Create new folder","IMAPviewItem"),1); | 189 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
190 | m->insertSeparator(); | 190 | m->insertSeparator(); |
191 | m->insertItem(QObject::tr("Disconnect","IMAPviewItem"),2); | 191 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
192 | } | 192 | } |
193 | return m; | 193 | return m; |
194 | } | 194 | } |
@@ -291,14 +291,14 @@ QPopupMenu * IMAPfolderItem::getContextMenu() | |||
291 | QPopupMenu *m = new QPopupMenu(0); | 291 | QPopupMenu *m = new QPopupMenu(0); |
292 | if (m) { | 292 | if (m) { |
293 | if (folder->may_select()) { | 293 | if (folder->may_select()) { |
294 | m->insertItem(QObject::tr("Refresh header list","IMAPfolderItem"),0); | 294 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
295 | m->insertItem(QObject::tr("Delete all mails","IMAPfolderItem"),1); | 295 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
296 | } | 296 | } |
297 | if (folder->no_inferior()==false) { | 297 | if (folder->no_inferior()==false) { |
298 | m->insertItem(QObject::tr("Create new subfolder","IMAPfolderItem"),2); | 298 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
299 | } | 299 | } |
300 | if (folder->getDisplayName().lower()!="inbox") { | 300 | if (folder->getDisplayName().lower()!="inbox") { |
301 | m->insertItem(QObject::tr("Delete folder","IMAPfolderItem"),3); | 301 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | return m; | 304 | return m; |
@@ -306,10 +306,10 @@ QPopupMenu * IMAPfolderItem::getContextMenu() | |||
306 | 306 | ||
307 | void IMAPfolderItem::deleteAllMails() | 307 | void IMAPfolderItem::deleteAllMails() |
308 | { | 308 | { |
309 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails","IMAPfolderItem"), | 309 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), |
310 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>","IMAPfolderItem").arg(folder->getDisplayName()), | 310 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()), |
311 | QObject::tr("Yes","IMAPfolderItem"), | 311 | QObject::tr("Yes",contextName), |
312 | QObject::tr("No","IMAPfolderItem"),QString::null,1,1); | 312 | QObject::tr("No",contextName),QString::null,1,1); |
313 | qDebug("Auswahl: %i",yesno); | 313 | qDebug("Auswahl: %i",yesno); |
314 | if (yesno == 0) { | 314 | if (yesno == 0) { |
315 | if (imap->getWrapper()->deleteAllMail(folder)) { | 315 | if (imap->getWrapper()->deleteAllMail(folder)) { |
@@ -335,16 +335,21 @@ void IMAPfolderItem::createNewFolder() | |||
335 | 335 | ||
336 | void IMAPfolderItem::deleteFolder() | 336 | void IMAPfolderItem::deleteFolder() |
337 | { | 337 | { |
338 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder","IMAPfolderItem"), | 338 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
339 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>","IMAPfolderItem").arg(folder->getDisplayName()), | 339 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
340 | QObject::tr("Yes","IMAPfolderItem"), | 340 | QObject::tr("Yes",contextName), |
341 | QObject::tr("No","IMAPfolderItem"),QString::null,1,1); | 341 | QObject::tr("No",contextName),QString::null,1,1); |
342 | qDebug("Auswahl: %i",yesno); | 342 | qDebug("Auswahl: %i",yesno); |
343 | if (yesno == 0) { | 343 | if (yesno == 0) { |
344 | if (imap->getWrapper()->deleteMbox(folder)) { | 344 | if (imap->getWrapper()->deleteMbox(folder)) { |
345 | /* be carefull - after that this object is destroyd so don't call | 345 | QListView*v=listView(); |
346 | IMAPviewItem * box = imap; | ||
347 | /* be carefull - after that this object is destroyd so don't use | ||
346 | * any member of it after that call!!*/ | 348 | * any member of it after that call!!*/ |
347 | imap->refreshFolders(true); | 349 | imap->refreshFolders(true); |
350 | if (v) { | ||
351 | v->setSelected(box,true); | ||
352 | } | ||
348 | } | 353 | } |
349 | } | 354 | } |
350 | } | 355 | } |
@@ -375,6 +380,8 @@ void IMAPfolderItem::contextMenuSelected(int id) | |||
375 | * Generic stuff | 380 | * Generic stuff |
376 | */ | 381 | */ |
377 | 382 | ||
383 | const QString AccountViewItem::contextName="AccountViewItem"; | ||
384 | |||
378 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 385 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
379 | : QListView( parent, name, flags ) | 386 | : QListView( parent, name, flags ) |
380 | { | 387 | { |
@@ -490,6 +497,12 @@ AbstractMail *MBOXviewItem::getWrapper() | |||
490 | 497 | ||
491 | void MBOXviewItem::refresh( QList<RecMail> & ) | 498 | void MBOXviewItem::refresh( QList<RecMail> & ) |
492 | { | 499 | { |
500 | refresh(false); | ||
501 | } | ||
502 | |||
503 | void MBOXviewItem::refresh(bool force) | ||
504 | { | ||
505 | if (childCount()>0 && force==false) return; | ||
493 | QList<Folder> *folders = wrapper->listFolders(); | 506 | QList<Folder> *folders = wrapper->listFolders(); |
494 | QListViewItem *child = firstChild(); | 507 | QListViewItem *child = firstChild(); |
495 | while ( child ) { | 508 | while ( child ) { |
@@ -510,10 +523,46 @@ void MBOXviewItem::refresh( QList<RecMail> & ) | |||
510 | 523 | ||
511 | RecBody MBOXviewItem::fetchBody( const RecMail &mail ) | 524 | RecBody MBOXviewItem::fetchBody( const RecMail &mail ) |
512 | { | 525 | { |
513 | qDebug( "POP3 fetchBody" ); | 526 | qDebug( "MBOX fetchBody" ); |
514 | return wrapper->fetchBody( mail ); | 527 | return wrapper->fetchBody( mail ); |
515 | } | 528 | } |
516 | 529 | ||
530 | QPopupMenu * MBOXviewItem::getContextMenu() | ||
531 | { | ||
532 | QPopupMenu *m = new QPopupMenu(0); | ||
533 | if (m) { | ||
534 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | ||
535 | m->insertItem(QObject::tr("Create new folder",contextName),1); | ||
536 | } | ||
537 | return m; | ||
538 | } | ||
539 | |||
540 | void MBOXviewItem::createFolder() | ||
541 | { | ||
542 | Newmdirdlg ndirdlg(0,0,true); | ||
543 | ndirdlg.showMaximized(); | ||
544 | if (ndirdlg.exec()) { | ||
545 | QString ndir = ndirdlg.Newdir(); | ||
546 | if (wrapper->createMbox(ndir)) { | ||
547 | refresh(true); | ||
548 | } | ||
549 | } | ||
550 | } | ||
551 | |||
552 | void MBOXviewItem::contextMenuSelected(int which) | ||
553 | { | ||
554 | switch (which) { | ||
555 | case 0: | ||
556 | refresh(true); | ||
557 | break; | ||
558 | case 1: | ||
559 | createFolder(); | ||
560 | break; | ||
561 | default: | ||
562 | break; | ||
563 | } | ||
564 | } | ||
565 | |||
517 | MBOXfolderItem::~MBOXfolderItem() | 566 | MBOXfolderItem::~MBOXfolderItem() |
518 | { | 567 | { |
519 | delete folder; | 568 | delete folder; |
@@ -544,3 +593,63 @@ RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) | |||
544 | { | 593 | { |
545 | return mbox->getWrapper()->fetchBody(aMail); | 594 | return mbox->getWrapper()->fetchBody(aMail); |
546 | } | 595 | } |
596 | |||
597 | void MBOXfolderItem::deleteAllMails() | ||
598 | { | ||
599 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | ||
600 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()), | ||
601 | QObject::tr("Yes",contextName), | ||
602 | QObject::tr("No",contextName),QString::null,1,1); | ||
603 | qDebug("Auswahl: %i",yesno); | ||
604 | if (yesno == 0) { | ||
605 | if (mbox->getWrapper()->deleteAllMail(folder)) { | ||
606 | AccountView * view = (AccountView*)listView(); | ||
607 | if (view) view->refreshCurrent(); | ||
608 | } | ||
609 | } | ||
610 | } | ||
611 | |||
612 | void MBOXfolderItem::deleteFolder() | ||
613 | { | ||
614 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | ||
615 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | ||
616 | QObject::tr("Yes",contextName), | ||
617 | QObject::tr("No",contextName),QString::null,1,1); | ||
618 | qDebug("Auswahl: %i",yesno); | ||
619 | if (yesno == 0) { | ||
620 | if (mbox->getWrapper()->deleteMbox(folder)) { | ||
621 | QListView*v=listView(); | ||
622 | MBOXviewItem * box = mbox; | ||
623 | /* be carefull - after that this object is destroyd so don't use | ||
624 | * any member of it after that call!!*/ | ||
625 | mbox->refresh(true); | ||
626 | if (v) { | ||
627 | v->setSelected(box,true); | ||
628 | } | ||
629 | } | ||
630 | } | ||
631 | } | ||
632 | |||
633 | QPopupMenu * MBOXfolderItem::getContextMenu() | ||
634 | { | ||
635 | QPopupMenu *m = new QPopupMenu(0); | ||
636 | if (m) { | ||
637 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | ||
638 | m->insertItem(QObject::tr("Delete folder",contextName),1); | ||
639 | } | ||
640 | return m; | ||
641 | } | ||
642 | |||
643 | void MBOXfolderItem::contextMenuSelected(int which) | ||
644 | { | ||
645 | switch(which) { | ||
646 | case 0: | ||
647 | deleteAllMails(); | ||
648 | break; | ||
649 | case 1: | ||
650 | deleteFolder(); | ||
651 | break; | ||
652 | default: | ||
653 | break; | ||
654 | } | ||
655 | } | ||