author | alwin <alwin> | 2003-12-28 02:45:07 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-28 02:45:07 (UTC) |
commit | d1a7eb08cad465c5fc0de53f75aaecf7803f0945 (patch) (side-by-side diff) | |
tree | 422b73af760cdd44e4fbbc96bd6876a15939ff19 /noncore/net/mail/accountview.cpp | |
parent | e889485e945d8fa9564566f286114be10d2a1ce5 (diff) | |
download | opie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.zip opie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.tar.gz opie-d1a7eb08cad465c5fc0de53f75aaecf7803f0945.tar.bz2 |
- dir handling for mbox accounts (delete, new, delete all mail)
- fixed memory leaks in mbox account class
- reduced count of used string constants while using "tr" with context string
- mbox displays messages into global status bar
- fixed a possible raise condition when deleting a mail directory
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 @@ -186,8 +186,8 @@ QPopupMenu * IMAPviewItem::getContextMenu() QPopupMenu *m = new QPopupMenu(0); if (m) { - m->insertItem(QObject::tr("Refresh folder list","IMAPviewItem"),0); - m->insertItem(QObject::tr("Create new folder","IMAPviewItem"),1); + m->insertItem(QObject::tr("Refresh folder list",contextName),0); + m->insertItem(QObject::tr("Create new folder",contextName),1); m->insertSeparator(); - m->insertItem(QObject::tr("Disconnect","IMAPviewItem"),2); + m->insertItem(QObject::tr("Disconnect",contextName),2); } return m; @@ -292,12 +292,12 @@ QPopupMenu * IMAPfolderItem::getContextMenu() if (m) { if (folder->may_select()) { - m->insertItem(QObject::tr("Refresh header list","IMAPfolderItem"),0); - m->insertItem(QObject::tr("Delete all mails","IMAPfolderItem"),1); + m->insertItem(QObject::tr("Refresh header list",contextName),0); + m->insertItem(QObject::tr("Delete all mails",contextName),1); } if (folder->no_inferior()==false) { - m->insertItem(QObject::tr("Create new subfolder","IMAPfolderItem"),2); + m->insertItem(QObject::tr("Create new subfolder",contextName),2); } if (folder->getDisplayName().lower()!="inbox") { - m->insertItem(QObject::tr("Delete folder","IMAPfolderItem"),3); + m->insertItem(QObject::tr("Delete folder",contextName),3); } } @@ -307,8 +307,8 @@ QPopupMenu * IMAPfolderItem::getContextMenu() void IMAPfolderItem::deleteAllMails() { - int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails","IMAPfolderItem"), - QObject::tr("<center>Realy delete all mails in box <br>%1</center>","IMAPfolderItem").arg(folder->getDisplayName()), - QObject::tr("Yes","IMAPfolderItem"), - QObject::tr("No","IMAPfolderItem"),QString::null,1,1); + int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), + QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()), + QObject::tr("Yes",contextName), + QObject::tr("No",contextName),QString::null,1,1); qDebug("Auswahl: %i",yesno); if (yesno == 0) { @@ -336,14 +336,19 @@ void IMAPfolderItem::createNewFolder() void IMAPfolderItem::deleteFolder() { - int yesno = QMessageBox::warning(0,QObject::tr("Delete folder","IMAPfolderItem"), - QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>","IMAPfolderItem").arg(folder->getDisplayName()), - QObject::tr("Yes","IMAPfolderItem"), - QObject::tr("No","IMAPfolderItem"),QString::null,1,1); + int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), + QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), + QObject::tr("Yes",contextName), + QObject::tr("No",contextName),QString::null,1,1); qDebug("Auswahl: %i",yesno); if (yesno == 0) { if (imap->getWrapper()->deleteMbox(folder)) { - /* be carefull - after that this object is destroyd so don't call + QListView*v=listView(); + IMAPviewItem * box = imap; + /* be carefull - after that this object is destroyd so don't use * any member of it after that call!!*/ imap->refreshFolders(true); + if (v) { + v->setSelected(box,true); + } } } @@ -376,4 +381,6 @@ void IMAPfolderItem::contextMenuSelected(int id) */ +const QString AccountViewItem::contextName="AccountViewItem"; + AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) : QListView( parent, name, flags ) @@ -491,4 +498,10 @@ AbstractMail *MBOXviewItem::getWrapper() void MBOXviewItem::refresh( QList<RecMail> & ) { + refresh(false); +} + +void MBOXviewItem::refresh(bool force) +{ + if (childCount()>0 && force==false) return; QList<Folder> *folders = wrapper->listFolders(); QListViewItem *child = firstChild(); @@ -511,8 +524,44 @@ void MBOXviewItem::refresh( QList<RecMail> & ) RecBody MBOXviewItem::fetchBody( const RecMail &mail ) { - qDebug( "POP3 fetchBody" ); + qDebug( "MBOX fetchBody" ); return wrapper->fetchBody( mail ); } +QPopupMenu * MBOXviewItem::getContextMenu() +{ + QPopupMenu *m = new QPopupMenu(0); + if (m) { + m->insertItem(QObject::tr("Refresh folder list",contextName),0); + m->insertItem(QObject::tr("Create new folder",contextName),1); + } + return m; +} + +void MBOXviewItem::createFolder() +{ + Newmdirdlg ndirdlg(0,0,true); + ndirdlg.showMaximized(); + if (ndirdlg.exec()) { + QString ndir = ndirdlg.Newdir(); + if (wrapper->createMbox(ndir)) { + refresh(true); + } + } +} + +void MBOXviewItem::contextMenuSelected(int which) +{ + switch (which) { + case 0: + refresh(true); + break; + case 1: + createFolder(); + break; + default: + break; + } +} + MBOXfolderItem::~MBOXfolderItem() { @@ -545,2 +594,62 @@ RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) return mbox->getWrapper()->fetchBody(aMail); } + +void MBOXfolderItem::deleteAllMails() +{ + int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), + QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).arg(folder->getDisplayName()), + QObject::tr("Yes",contextName), + QObject::tr("No",contextName),QString::null,1,1); + qDebug("Auswahl: %i",yesno); + if (yesno == 0) { + if (mbox->getWrapper()->deleteAllMail(folder)) { + AccountView * view = (AccountView*)listView(); + if (view) view->refreshCurrent(); + } + } +} + +void MBOXfolderItem::deleteFolder() +{ + int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), + QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), + QObject::tr("Yes",contextName), + QObject::tr("No",contextName),QString::null,1,1); + qDebug("Auswahl: %i",yesno); + if (yesno == 0) { + if (mbox->getWrapper()->deleteMbox(folder)) { + QListView*v=listView(); + MBOXviewItem * box = mbox; + /* be carefull - after that this object is destroyd so don't use + * any member of it after that call!!*/ + mbox->refresh(true); + if (v) { + v->setSelected(box,true); + } + } + } +} + +QPopupMenu * MBOXfolderItem::getContextMenu() +{ + QPopupMenu *m = new QPopupMenu(0); + if (m) { + m->insertItem(QObject::tr("Delete all mails",contextName),0); + m->insertItem(QObject::tr("Delete folder",contextName),1); + } + return m; +} + +void MBOXfolderItem::contextMenuSelected(int which) +{ + switch(which) { + case 0: + deleteAllMails(); + break; + case 1: + deleteFolder(); + break; + default: + break; + } +} |