Diffstat (limited to 'noncore/net/mail/accountitem.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/accountitem.cpp | 232 |
1 files changed, 122 insertions, 110 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index 10db2c6..f7fdccd 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp @@ -84,20 +84,14 @@ RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) } -QPopupMenu * POP3viewItem::getContextMenu() +QMap<int,QString> POP3viewItem::serverMenu() { - QPopupMenu *m = new QPopupMenu(0); - if (m) - { - if (!account->getOffline()) - { - m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); - m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); - } - else - { - m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); - } + QMap<int,QString> _entries; + if (!account->getOffline()) { + _entries[SERVER_MENU_DISCONNECT]=QObject::tr("Disconnect",contextName); + _entries[SERVER_MENU_OFFLINE]=QObject::tr("Set offline",contextName); + } else { + _entries[SERVER_MENU_OFFLINE]=QObject::tr("Set online",contextName); } - return m; + return _entries; } @@ -126,5 +120,5 @@ void POP3viewItem::setOnOffline() } -void POP3viewItem::contextMenuSelected(int which) +bool POP3viewItem::contextMenuSelected(int which) { switch (which) @@ -137,4 +131,5 @@ void POP3viewItem::contextMenuSelected(int which) break; } + return false; } @@ -168,14 +163,11 @@ RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) } -QPopupMenu * POP3folderItem::getContextMenu() +QMap<int,QString> POP3folderItem::folderMenu() { - QPopupMenu *m = new QPopupMenu(0); - if (m) - { - m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); - m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); - m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); - } - return m; + QMap<int,QString> _entries; + _entries[FOLDER_MENU_REFRESH_HEADER]=QObject::tr("Refresh header list",contextName); + _entries[FOLDER_MENU_DELETE_ALL_MAILS]=QObject::tr("Delete all mails",contextName); + _entries[FOLDER_MENU_MOVE_MAILS]=QObject::tr("Move/Copie all mails",contextName); + return _entries; } @@ -187,5 +179,5 @@ void POP3folderItem::downloadMails() } -void POP3folderItem::contextMenuSelected(int which) +bool POP3folderItem::contextMenuSelected(int which) { AccountView * view = (AccountView*)listView(); @@ -206,4 +198,5 @@ void POP3folderItem::contextMenuSelected(int which) break; } + return false; } @@ -275,21 +268,16 @@ RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) } -QPopupMenu * NNTPviewItem::getContextMenu() -{ - QPopupMenu *m = new QPopupMenu(0); - if (m) +QMap<int,QString> NNTPviewItem::serverMenu() { + QMap<int,QString> _entries; if (!account->getOffline()) { - m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); - m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); - m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),SERVER_MENU_SUBSCRIBE); - } - else - { - m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); - } + _entries[SERVER_MENU_DISCONNECT]=QObject::tr("Disconnect",contextName); + _entries[SERVER_MENU_OFFLINE]=QObject::tr("Set offline",contextName); + _entries[SERVER_MENU_SUBSCRIBE]=QObject::tr("(Un-)Subscribe groups",contextName); + } else { + _entries[SERVER_MENU_OFFLINE]=QObject::tr("Set online",contextName); } - return m; + return _entries; } @@ -327,5 +315,5 @@ void NNTPviewItem::setOnOffline() } -void NNTPviewItem::contextMenuSelected(int which) +bool NNTPviewItem::contextMenuSelected(int which) { switch (which) @@ -341,4 +329,5 @@ void NNTPviewItem::contextMenuSelected(int which) break; } + return false; } @@ -372,13 +361,10 @@ RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) } -QPopupMenu * NNTPfolderItem::getContextMenu() +QMap<int,QString> NNTPfolderItem::folderMenu() { - QPopupMenu *m = new QPopupMenu(0); - if (m) - { - m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); - m->insertItem(QObject::tr("Copy all postings",contextName),FOLDER_MENU_MOVE_MAILS); - } - return m; + QMap<int,QString> _entries; + _entries[FOLDER_MENU_REFRESH_HEADER]=QObject::tr("Refresh header list",contextName); + _entries[FOLDER_MENU_MOVE_MAILS]=QObject::tr("Copy all postings",contextName); + return _entries; } @@ -390,5 +376,5 @@ void NNTPfolderItem::downloadMails() } -void NNTPfolderItem::contextMenuSelected(int which) +bool NNTPfolderItem::contextMenuSelected(int which) { AccountView * view = (AccountView*)listView(); @@ -406,4 +392,5 @@ void NNTPfolderItem::contextMenuSelected(int which) break; } + return false; } @@ -492,23 +479,16 @@ void IMAPviewItem::refreshFolders(bool force) } -QPopupMenu * IMAPviewItem::getContextMenu() +QMap<int,QString> IMAPviewItem::serverMenu() { - QPopupMenu *m = new QPopupMenu(0); - if (m) - { - if (!account->getOffline()) - { - m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); - m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); - m->insertSeparator(); - m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); - m->insertItem(QObject::tr("Create new folder",contextName),SERVER_MENU_CREATE_FOLDER); - } - else - { - m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); - } + QMap<int,QString> e; + if (!account->getOffline()) { + e[SERVER_MENU_DISCONNECT]=QObject::tr("Disconnect",contextName); + e[SERVER_MENU_OFFLINE]=QObject::tr("Set offline",contextName); + e[SERVER_MENU_REFRESH_FOLDER]=QObject::tr("Refresh folder list",contextName); + e[SERVER_MENU_CREATE_FOLDER]=QObject::tr("Create new folder",contextName); + } else { + e[SERVER_MENU_OFFLINE]=QObject::tr("Set online",contextName); } - return m; + return e; } @@ -533,5 +513,5 @@ void IMAPviewItem::createNewFolder() } -void IMAPviewItem::contextMenuSelected(int id) +bool IMAPviewItem::contextMenuSelected(int id) { odebug << "Id selected: " << id << "" << oendl; @@ -562,4 +542,5 @@ void IMAPviewItem::contextMenuSelected(int id) break; } + return false; } @@ -629,25 +610,19 @@ RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) } -QPopupMenu * IMAPfolderItem::getContextMenu() -{ - QPopupMenu *m = new QPopupMenu(0); - if (m) - { - if (folder->may_select()) +QMap<int,QString> IMAPfolderItem::folderMenu() { - m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); - m->insertItem(QObject::tr("Move/Copy all mails",contextName),FOLDER_MENU_MOVE_MAILS); - m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); + QMap<int,QString> e; + if (folder->may_select()) { + e[FOLDER_MENU_REFRESH_HEADER]=QObject::tr("Refresh header list",contextName); + e[FOLDER_MENU_MOVE_MAILS]=QObject::tr("Move/Copy all mails",contextName); + e[FOLDER_MENU_DELETE_ALL_MAILS]=QObject::tr("Delete all mails",contextName); } - if (folder->no_inferior()==false) - { - m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); + if (folder->no_inferior()==false) { + e[FOLDER_MENU_NEW_SUBFOLDER]=QObject::tr("Create new subfolder",contextName); } - if (folder->getDisplayName().lower()!="inbox") - { - m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); + if (folder->getDisplayName().lower()!="inbox") { + e[FOLDER_MENU_DELETE_FOLDER]=QObject::tr("Delete folder",contextName); } - } - return m; + return e; } @@ -667,5 +642,5 @@ void IMAPfolderItem::createNewFolder() } -void IMAPfolderItem::deleteFolder() +bool IMAPfolderItem::deleteFolder() { int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), @@ -687,6 +662,8 @@ void IMAPfolderItem::deleteFolder() v->setSelected(box,true); } + return true; } } + return false; } @@ -698,5 +675,5 @@ void IMAPfolderItem::downloadMails() } -void IMAPfolderItem::contextMenuSelected(int id) +bool IMAPfolderItem::contextMenuSelected(int id) { odebug << "Selected id: " << id << "" << oendl; @@ -717,5 +694,5 @@ void IMAPfolderItem::contextMenuSelected(int id) case FOLDER_MENU_DELETE_FOLDER: if (folder->getDisplayName().lower()!="inbox") { - deleteFolder(); + return deleteFolder(); } break; @@ -726,4 +703,5 @@ void IMAPfolderItem::contextMenuSelected(int id) break; } + return false; } @@ -813,15 +791,19 @@ RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) } -QPopupMenu * MHviewItem::getContextMenu() -{ - QPopupMenu *m = new QPopupMenu(0); - if (m) +QMap<int,QString> MHviewItem::serverMenu() { - m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); - m->insertItem(QObject::tr("Create new folder",contextName),FOLDER_MENU_NEW_SUBFOLDER); - m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); - m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); + QMap<int,QString> e; + e[SERVER_MENU_REFRESH_FOLDER]=QObject::tr("Refresh folder list",contextName); + return e; } - return m; + +QMap<int,QString> MHviewItem::folderMenu() +{ + QMap<int,QString> e; + e[FOLDER_MENU_REFRESH_HEADER]=QObject::tr("Refresh header list",contextName); + e[FOLDER_MENU_NEW_SUBFOLDER]=QObject::tr("Create new folder",contextName); + e[FOLDER_MENU_DELETE_ALL_MAILS]=QObject::tr("Delete all mails",contextName); + e[FOLDER_MENU_MOVE_MAILS]=QObject::tr("Move/Copie all mails",contextName); + return e; } @@ -851,5 +833,5 @@ QStringList MHviewItem::subFolders() } -void MHviewItem::contextMenuSelected(int which) +bool MHviewItem::contextMenuSelected(int which) { AccountView*view = 0; @@ -876,4 +858,5 @@ void MHviewItem::contextMenuSelected(int which) break; } + return false; } @@ -939,5 +922,5 @@ RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) } -void MHfolderItem::deleteFolder() +bool MHfolderItem::deleteFolder() { int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), @@ -959,20 +942,19 @@ void MHfolderItem::deleteFolder() v->setSelected(box,true); } + return true; } } + return false; } -QPopupMenu * MHfolderItem::getContextMenu() +QMap<int,QString> MHfolderItem::folderMenu() { - QPopupMenu *m = new QPopupMenu(0); - if (m) - { - m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); - m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); - m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); - m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); - m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); - } - return m; + QMap<int,QString> e; + e[FOLDER_MENU_NEW_SUBFOLDER]=QObject::tr("Create new subfolder",contextName); + e[FOLDER_MENU_REFRESH_HEADER]=QObject::tr("Refresh header list",contextName); + e[FOLDER_MENU_MOVE_MAILS]=QObject::tr("Move/Copie all mails",contextName); + e[FOLDER_MENU_DELETE_ALL_MAILS]=QObject::tr("Delete all mails",contextName); + e[FOLDER_MENU_DELETE_FOLDER]=QObject::tr("Delete folder",contextName); + return e; } @@ -1005,5 +987,5 @@ void MHfolderItem::createFolder() } -void MHfolderItem::contextMenuSelected(int which) +bool MHfolderItem::contextMenuSelected(int which) { AccountView*view = 0; @@ -1014,5 +996,5 @@ void MHfolderItem::contextMenuSelected(int which) break; case FOLDER_MENU_DELETE_FOLDER: - deleteFolder(); + return deleteFolder(); break; case FOLDER_MENU_MOVE_MAILS: @@ -1029,4 +1011,5 @@ void MHfolderItem::contextMenuSelected(int which) break; } + return false; } @@ -1151,2 +1134,31 @@ bool AccountViewItem::isDraftfolder() return false; } + +QMap<int,QString> AccountViewItem::serverMenu() +{ + return QMap<int,QString>(); +} + +QMap<int,QString> AccountViewItem::folderMenu() +{ + return QMap<int,QString>(); +} + +QPopupMenu * AccountViewItem::getContextMenu() +{ + QPopupMenu *m = new QPopupMenu(0); + if (m) + { + QMap<int,QString> entries; + entries = folderMenu(); + QMap<int,QString>::Iterator it; + for (it=entries.begin();it!=entries.end();++it) { + m->insertItem(it.data(),it.key()); + } + entries = serverMenu(); + for (it=entries.begin();it!=entries.end();++it) { + m->insertItem(it.data(),it.key()); + } + } + return m; +} |