Diffstat (limited to 'noncore/net/mail/accountitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/accountitem.cpp | 240 |
1 files changed, 126 insertions, 114 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 @@ -62,170 +62,163 @@ void POP3viewItem::refresh() QValueList<FolderP> *folders = wrapper->listFolders(); QListViewItem *child = firstChild(); while ( child ) { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } QValueList<FolderP>::ConstIterator it; QListViewItem*item = 0; for ( it = folders->begin(); it!=folders->end(); ++it) { item = new POP3folderItem( (*it), this , item ); item->setSelectable( (*it)->may_select()); } delete folders; } RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) { odebug << "POP3 fetchBody" << oendl; return wrapper->fetchBody( 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; } void POP3viewItem::disconnect() { QListViewItem *child = firstChild(); while ( child ) { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } wrapper->logout(); } void POP3viewItem::setOnOffline() { if (!account->getOffline()) { disconnect(); } account->setOffline(!account->getOffline()); account->save(); SETPIX(PIXMAP_POP3FOLDER); refresh(); } -void POP3viewItem::contextMenuSelected(int which) +bool POP3viewItem::contextMenuSelected(int which) { switch (which) { case SERVER_MENU_DISCONNECT: disconnect(); break; case SERVER_MENU_OFFLINE: setOnOffline(); break; } + return false; } POP3folderItem::~POP3folderItem() {} POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) : AccountViewItem(folderInit,parent,after ) { pop3 = parent; if (folder->getDisplayName().lower()!="inbox") { setPixmap( 0, PIXMAP_POP3FOLDER ); } else { setPixmap( 0, PIXMAP_INBOXFOLDER); } setText( 0, folder->getDisplayName() ); } void POP3folderItem::refresh(QValueList<RecMailP>&target) { if (folder->may_select()) pop3->getWrapper()->listMessages( folder->getName(),target ); } RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) { return pop3->getWrapper()->fetchBody(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; } void POP3folderItem::downloadMails() { AccountView*bl = pop3->accountView(); if (!bl) return; bl->downloadMails(folder,pop3->getWrapper()); } -void POP3folderItem::contextMenuSelected(int which) +bool POP3folderItem::contextMenuSelected(int which) { AccountView * view = (AccountView*)listView(); switch (which) { case FOLDER_MENU_REFRESH_HEADER: /* must be 'cause pop3 lists are cached */ pop3->getWrapper()->logout(); view->refreshCurrent(); break; case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(pop3->getWrapper(),folder); break; case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; default: break; } + return false; } /** * NNTP Account stuff */ NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) : AccountViewItem( parent ) { account = a; wrapper = AbstractMail::getWrapper( account ); //FIXME SETPIX(PIXMAP_POP3FOLDER); #if 0 if (!account->getOffline()) { setPixmap( 0, ); } else { setPixmap( 0, PIXMAP_OFFLINE ); } #endif setText( 0, account->getAccountName() ); setOpen( true ); @@ -253,179 +246,173 @@ void NNTPviewItem::refresh() QListViewItem *child = firstChild(); while ( child ) { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } QValueList<FolderP>::ConstIterator it; QListViewItem*item = 0; for ( it = folders->begin(); it!=folders->end(); ++it) { item = new NNTPfolderItem( (*it), this , item ); item->setSelectable( (*it)->may_select()); } delete folders; } RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) { odebug << "NNTP fetchBody" << oendl; return wrapper->fetchBody( mail ); } -QPopupMenu * NNTPviewItem::getContextMenu() +QMap<int,QString> NNTPviewItem::serverMenu() { - QPopupMenu *m = new QPopupMenu(0); - if (m) + QMap<int,QString> _entries; + if (!account->getOffline()) { - 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; } void NNTPviewItem::subscribeGroups() { NNTPGroupsDlg dlg(account); if (QPEApplication::execDialog(&dlg)== QDialog::Accepted ){ refresh(); } } void NNTPviewItem::disconnect() { QListViewItem *child = firstChild(); while ( child ) { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } wrapper->logout(); } void NNTPviewItem::setOnOffline() { if (!account->getOffline()) { disconnect(); } account->setOffline(!account->getOffline()); account->save(); //FIXME SETPIX(PIXMAP_POP3FOLDER); refresh(); } -void NNTPviewItem::contextMenuSelected(int which) +bool NNTPviewItem::contextMenuSelected(int which) { switch (which) { case SERVER_MENU_DISCONNECT: disconnect(); break; case SERVER_MENU_OFFLINE: setOnOffline(); break; case SERVER_MENU_SUBSCRIBE: subscribeGroups(); break; } + return false; } NNTPfolderItem::~NNTPfolderItem() {} NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) : AccountViewItem( folderInit, parent,after ) { nntp = parent; if (folder->getDisplayName().lower()!="inbox") { setPixmap( 0, PIXMAP_POP3FOLDER ); } else { setPixmap( 0, PIXMAP_INBOXFOLDER); } setText( 0, folder->getDisplayName() ); } void NNTPfolderItem::refresh(QValueList<RecMailP>&target) { if (folder->may_select()) nntp->getWrapper()->listMessages( folder->getName(),target ); } RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) { return nntp->getWrapper()->fetchBody(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; } void NNTPfolderItem::downloadMails() { AccountView*bl = nntp->accountView(); if (!bl) return; bl->downloadMails(folder,nntp->getWrapper()); } -void NNTPfolderItem::contextMenuSelected(int which) +bool NNTPfolderItem::contextMenuSelected(int which) { AccountView * view = (AccountView*)listView(); switch (which) { case FOLDER_MENU_REFRESH_HEADER: /* must be 'cause nntp lists are cached */ nntp->getWrapper()->logout(); view->refreshCurrent(); break; case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; default: break; } + return false; } /** * IMAP Account stuff */ IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) : AccountViewItem( parent ) { account = a; wrapper = AbstractMail::getWrapper( account ); SETPIX(PIXMAP_IMAPFOLDER); setText( 0, account->getAccountName() ); setOpen( true ); } IMAPviewItem::~IMAPviewItem() { delete wrapper; } AbstractMail *IMAPviewItem::getWrapper() { return wrapper; } @@ -470,118 +457,112 @@ void IMAPviewItem::refreshFolders(bool force) fname = (*it)->getDisplayName(); currentFolders.append((*it)->getName()); pos = fname.findRev((*it)->Separator()); if (pos != -1) { fname = fname.left(pos); } IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); if (pitem) { titem = item; item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); /* setup the short name */ item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); item = titem; } else { item = new IMAPfolderItem( (*it), this , item ); } } delete folders; } -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; } void IMAPviewItem::createNewFolder() { Newmdirdlg ndirdlg; if ( QPEApplication::execDialog( &ndirdlg )) { QString ndir = ndirdlg.Newdir(); bool makesubs = ndirdlg.subpossible(); QString delemiter = "/"; IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); if (item) { delemiter = item->Delemiter(); } if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { refreshFolders(true); } } } -void IMAPviewItem::contextMenuSelected(int id) +bool IMAPviewItem::contextMenuSelected(int id) { odebug << "Id selected: " << id << "" << oendl; switch (id) { case SERVER_MENU_REFRESH_FOLDER: refreshFolders(true); break; case SERVER_MENU_CREATE_FOLDER: createNewFolder(); break; case SERVER_MENU_DISCONNECT: removeChilds(); wrapper->logout(); break; case SERVER_MENU_OFFLINE: if (account->getOffline()==false) { removeChilds(); wrapper->logout(); } account->setOffline(!account->getOffline()); account->save(); SETPIX(PIXMAP_IMAPFOLDER); refreshFolders(false); break; default: break; } + return false; } RECBODYP IMAPviewItem::fetchBody(const RecMailP&) { return new RecBody(); } bool IMAPviewItem::offline() { return account->getOffline(); } IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) : AccountViewItem( folderInit, parent , after ) { imap = parent; if (folder->getDisplayName().lower()!="inbox") { setPixmap( 0, PIXMAP_IMAPFOLDER ); } else { setPixmap( 0, PIXMAP_INBOXFOLDER); } @@ -607,145 +588,142 @@ IMAPfolderItem::~IMAPfolderItem() {} const QString& IMAPfolderItem::Delemiter()const { return folder->Separator(); } void IMAPfolderItem::refresh(QValueList<RecMailP>&target) { if (folder->may_select()) { imap->getWrapper()->listMessages( folder->getName(),target ); } else { target.clear(); } } RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) { return imap->getWrapper()->fetchBody(aMail); } -QPopupMenu * IMAPfolderItem::getContextMenu() +QMap<int,QString> IMAPfolderItem::folderMenu() { - QPopupMenu *m = new QPopupMenu(0); - if (m) - { - if (folder->may_select()) - { - 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); - } - if (folder->no_inferior()==false) - { - m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); - } - if (folder->getDisplayName().lower()!="inbox") - { - m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); - } + 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); } - return m; + if (folder->no_inferior()==false) { + e[FOLDER_MENU_NEW_SUBFOLDER]=QObject::tr("Create new subfolder",contextName); + } + if (folder->getDisplayName().lower()!="inbox") { + e[FOLDER_MENU_DELETE_FOLDER]=QObject::tr("Delete folder",contextName); + } + return e; } void IMAPfolderItem::createNewFolder() { Newmdirdlg ndirdlg; if ( QPEApplication::execDialog( &ndirdlg ) ) { QString ndir = ndirdlg.Newdir(); bool makesubs = ndirdlg.subpossible(); QString delemiter = Delemiter(); if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { imap->refreshFolders(true); } } } -void IMAPfolderItem::deleteFolder() +bool IMAPfolderItem::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); odebug << "Auswahl: " << yesno << "" << oendl; if (yesno == 0) { if (imap->getWrapper()->deleteMbox(folder)) { 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); } + return true; } } + return false; } void IMAPfolderItem::downloadMails() { AccountView*bl = imap->accountView(); if (!bl) return; bl->downloadMails(folder,imap->getWrapper()); } -void IMAPfolderItem::contextMenuSelected(int id) +bool IMAPfolderItem::contextMenuSelected(int id) { odebug << "Selected id: " << id << "" << oendl; AccountView * view = (AccountView*)listView(); switch(id) { case FOLDER_MENU_REFRESH_HEADER: view->refreshCurrent(); break; case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(imap->getWrapper(),folder); break; case FOLDER_MENU_NEW_SUBFOLDER: if (folder->no_inferior()==false) { createNewFolder(); } break; case FOLDER_MENU_DELETE_FOLDER: if (folder->getDisplayName().lower()!="inbox") { - deleteFolder(); + return deleteFolder(); } break; case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; default: break; } + return false; } /** * MH Account stuff */ /* MH is a little bit different - the top folder can contains messages other than in IMAP and POP3 and MBOX */ MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) : AccountViewItem( parent ) { m_Path = aPath; /* be carefull - the space within settext is wanted - thats why the string twice */ wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); setPixmap( 0, PIXMAP_LOCALFOLDER ); setText( 0, " Local Folders" ); setOpen( true ); folder = 0; } MHviewItem::~MHviewItem() { delete wrapper; } @@ -791,111 +769,116 @@ void MHviewItem::refresh(bool force) } else { pmaster = 0; } if (pmaster) { item = new MHfolderItem( (*it), pmaster, item, this ); } else { item = new MHfolderItem( (*it), this , item ); } item->setSelectable((*it)->may_select()); } delete folders; } RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) { odebug << "MH fetchBody" << oendl; return wrapper->fetchBody( mail ); } -QPopupMenu * MHviewItem::getContextMenu() +QMap<int,QString> MHviewItem::serverMenu() { - QPopupMenu *m = new QPopupMenu(0); - if (m) - { - 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); - } - return m; + QMap<int,QString> e; + e[SERVER_MENU_REFRESH_FOLDER]=QObject::tr("Refresh folder list",contextName); + return e; +} + +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; } void MHviewItem::createFolder() { Newmdirdlg ndirdlg(0,0,true); if ( QPEApplication::execDialog( &ndirdlg ) ) { QString ndir = ndirdlg.Newdir(); if (wrapper->createMbox(ndir)) { refresh(true); } } } void MHviewItem::downloadMails() { AccountView*bl = accountView(); if (!bl) return; bl->downloadMails(folder,getWrapper()); } QStringList MHviewItem::subFolders() { return currentFolders; } -void MHviewItem::contextMenuSelected(int which) +bool MHviewItem::contextMenuSelected(int which) { AccountView*view = 0; switch (which) { case SERVER_MENU_REFRESH_FOLDER: refresh(true); break; case FOLDER_MENU_NEW_SUBFOLDER: createFolder(); break; case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(getWrapper(),folder); break; case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; case FOLDER_MENU_REFRESH_HEADER: view = (AccountView*)listView(); if (view) view->refreshCurrent(); break; default: break; } + return false; } MHfolderItem::~MHfolderItem() {} MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) : AccountViewItem(folderInit, parent,after ) { mbox = parent; initName(); } MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) : AccountViewItem(folderInit, parent,after ) { folder = folderInit; mbox = master; initName(); } void MHfolderItem::initName() { QString bName = folder->getDisplayName(); if (bName.startsWith("/")&&bName.length()>1) @@ -917,138 +900,138 @@ void MHfolderItem::initName() } else if (bName.lower() == "drafts") { setPixmap(0, Resource::loadPixmap("edit")); } else { setPixmap( 0, PIXMAP_MBOXFOLDER ); } setText( 0, bName ); } const FolderP&MHfolderItem::getFolder()const { return folder; } void MHfolderItem::refresh(QValueList<RecMailP>&target) { if (folder->may_select()) mbox->getWrapper()->listMessages( folder->getName(),target ); } RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) { return mbox->getWrapper()->fetchBody(aMail); } -void MHfolderItem::deleteFolder() +bool MHfolderItem::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); odebug << "Auswahl: " << yesno << "" << oendl; if (yesno == 0) { if (mbox->getWrapper()->deleteMbox(folder)) { QListView*v=listView(); MHviewItem * 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); } + 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; } void MHfolderItem::downloadMails() { AccountView*bl = mbox->accountView(); if (!bl) return; bl->downloadMails(folder,mbox->getWrapper()); } void MHfolderItem::createFolder() { Newmdirdlg ndirdlg(0,0,true); if ( QPEApplication::execDialog( &ndirdlg ) ) { QString ndir = ndirdlg.Newdir(); if (mbox->getWrapper()->createMbox(ndir,folder)) { QListView*v=listView(); MHviewItem * 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); } } } } -void MHfolderItem::contextMenuSelected(int which) +bool MHfolderItem::contextMenuSelected(int which) { AccountView*view = 0; switch(which) { case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(mbox->getWrapper(),folder); break; case FOLDER_MENU_DELETE_FOLDER: - deleteFolder(); + return deleteFolder(); break; case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; case FOLDER_MENU_NEW_SUBFOLDER: createFolder(); break; case FOLDER_MENU_REFRESH_HEADER: view = (AccountView*)listView(); if (view) view->refreshCurrent(); break; default: break; } + return false; } bool MHfolderItem::isDraftfolder() { if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; return false; } /** * Generic stuff */ const QString AccountViewItem::contextName="AccountViewItem"; AccountViewItem::AccountViewItem( AccountView *parent ) : QListViewItem( parent ) { init(); m_Backlink = parent; } AccountViewItem::AccountViewItem( QListViewItem *parent) : QListViewItem( parent),folder(0) { @@ -1129,24 +1112,53 @@ AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem* while (pitem) { if (pitem->matchName(path)) { break; } if (pitem->childCount()>0) { sitem = findSubItem(path,pitem); if (sitem) { pitem = sitem; break; } } pitem=(AccountViewItem*)pitem->nextSibling(); } return pitem; } 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; +} |