-rw-r--r-- | noncore/net/mail/accountitem.cpp | 240 | ||||
-rw-r--r-- | noncore/net/mail/accountitem.h | 50 | ||||
-rw-r--r-- | noncore/net/mail/accountview.cpp | 29 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 8 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 23 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 12 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 41 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.h | 8 |
8 files changed, 249 insertions, 162 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 @@ -78,32 +78,26 @@ void POP3viewItem::refresh() } 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; @@ -120,27 +114,28 @@ void POP3viewItem::setOnOffline() 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 ) { @@ -162,36 +157,33 @@ void POP3folderItem::refresh(QValueList<RecMailP>&target) 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(); @@ -200,16 +192,17 @@ void POP3folderItem::contextMenuSelected(int which) 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 ) { @@ -269,33 +262,28 @@ void NNTPviewItem::refresh() } 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(); } @@ -321,30 +309,31 @@ void NNTPviewItem::setOnOffline() } 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 ) { @@ -366,50 +355,48 @@ void NNTPfolderItem::refresh(QValueList<RecMailP>&target) 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 ) { @@ -486,35 +473,28 @@ void IMAPviewItem::refreshFolders(bool force) 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(); @@ -527,17 +507,17 @@ void IMAPviewItem::createNewFolder() } 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: @@ -556,16 +536,17 @@ void IMAPviewItem::contextMenuSelected(int id) 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() @@ -623,37 +604,31 @@ void IMAPfolderItem::refresh(QValueList<RecMailP>&target) } } 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(); @@ -661,17 +636,17 @@ void IMAPfolderItem::createNewFolder() 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) { @@ -681,28 +656,30 @@ void IMAPfolderItem::deleteFolder() 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; @@ -711,25 +688,26 @@ void IMAPfolderItem::contextMenuSelected(int id) 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 ) @@ -807,27 +785,31 @@ void MHviewItem::refresh(bool force) } 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(); @@ -845,17 +827,17 @@ void MHviewItem::downloadMails() 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; @@ -870,16 +852,17 @@ void MHviewItem::contextMenuSelected(int which) 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 ) { @@ -933,17 +916,17 @@ void MHfolderItem::refresh(QValueList<RecMailP>&target) 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) { @@ -953,32 +936,31 @@ void MHfolderItem::deleteFolder() 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()); } @@ -999,40 +981,41 @@ void MHfolderItem::createFolder() 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; } @@ -1145,8 +1128,37 @@ AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem* } 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; +} diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h index b2c50a1..6518899 100644 --- a/noncore/net/mail/accountitem.h +++ b/noncore/net/mail/accountitem.h @@ -1,14 +1,16 @@ #ifndef __ACCOUNT_ITEM #define __ACCOUNT_ITEM +#include <opie2/osmartpointer.h> + #include <qlistview.h> #include <qlist.h> -#include <opie2/osmartpointer.h> +#include <qmap.h> class POP3wrapper; class RecMail; class RecBody; class QPopupMenu; class Selectstore; class AccountView; class POP3account; @@ -26,26 +28,28 @@ public: AccountViewItem( AccountView *parent ); AccountViewItem( QListViewItem *parent); AccountViewItem( QListViewItem *parent , QListViewItem*after ); AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ); virtual ~AccountViewItem(); virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&)=0; virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&)=0; - virtual QPopupMenu * getContextMenu(){return 0;}; - virtual void contextMenuSelected(int){} + virtual QPopupMenu * getContextMenu(); + virtual bool contextMenuSelected(int){return false;} virtual AccountView*accountView(); virtual bool matchName(const QString&name)const; virtual bool isDraftfolder(); /* 1 - server * 2 - folder - * 3 - beides + * 3 - both */ virtual int isServer()const=0; + virtual QMap<int,QString> serverMenu(); + virtual QMap<int,QString> folderMenu(); protected: AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); virtual void init(); virtual void removeChilds(); virtual void deleteAllMail(AbstractMail*wrapper,const Opie::Core::OSmartPointer<Folder>&f); static const QString contextName; AccountView*m_Backlink; @@ -56,19 +60,19 @@ class POP3viewItem : public AccountViewItem { public: POP3viewItem( POP3account *a, AccountView *parent ); virtual ~POP3viewItem(); virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); AbstractMail *getWrapper(); - virtual QPopupMenu * getContextMenu(); - virtual void contextMenuSelected(int); + virtual bool contextMenuSelected(int); virtual int isServer()const{return 1;} + virtual QMap<int,QString> serverMenu(); protected: POP3account *account; virtual void refresh(); AbstractMail *wrapper; void disconnect(); void setOnOffline(); }; @@ -76,38 +80,38 @@ protected: class POP3folderItem : public AccountViewItem { public: POP3folderItem( const Opie::Core::OSmartPointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after ); virtual ~POP3folderItem(); virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); - virtual QPopupMenu * getContextMenu(); - virtual void contextMenuSelected(int); + virtual bool contextMenuSelected(int); virtual int isServer()const{return 2;} + virtual QMap<int,QString> folderMenu(); protected: void downloadMails(); POP3viewItem *pop3; }; class NNTPviewItem : public AccountViewItem { public: NNTPviewItem( NNTPaccount *a, AccountView *parent ); virtual ~NNTPviewItem(); virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); AbstractMail *getWrapper(); - virtual QPopupMenu * getContextMenu(); - virtual void contextMenuSelected(int); + virtual bool contextMenuSelected(int); virtual int isServer()const{return 1;} + virtual QMap<int,QString> serverMenu(); protected: NNTPaccount *account; virtual void refresh(); AbstractMail *wrapper; void disconnect(); void setOnOffline(); void subscribeGroups(); @@ -116,42 +120,41 @@ protected: class NNTPfolderItem : public AccountViewItem { public: NNTPfolderItem(const Opie::Core::OSmartPointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after ); virtual ~NNTPfolderItem(); virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); - virtual QPopupMenu * getContextMenu(); - virtual void contextMenuSelected(int); + virtual bool contextMenuSelected(int); virtual int isServer()const{return 2;} - + virtual QMap<int,QString> folderMenu(); protected: void downloadMails(); NNTPviewItem *nntp; }; class IMAPviewItem : public AccountViewItem { friend class IMAPfolderItem; public: IMAPviewItem( IMAPaccount *a, AccountView *parent ); virtual ~IMAPviewItem(); virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); AbstractMail *getWrapper(); - virtual QPopupMenu * getContextMenu(); - virtual void contextMenuSelected(int); + virtual bool contextMenuSelected(int); const QStringList&subFolders(); virtual void refreshFolders(bool force=false); virtual int isServer()const{return 1;} bool offline(); + virtual QMap<int,QString> serverMenu(); protected: virtual void createNewFolder(); IMAPaccount *account; AbstractMail *wrapper; QStringList currentFolders; }; @@ -159,42 +162,43 @@ class IMAPfolderItem : public AccountViewItem { public: IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after ); IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); virtual ~IMAPfolderItem(); virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); - virtual QPopupMenu * getContextMenu(); - virtual void contextMenuSelected(int); + virtual bool contextMenuSelected(int); virtual const QString& Delemiter()const; virtual int isServer()const{return 2;} + virtual QMap<int,QString> folderMenu(); protected: virtual void createNewFolder(); - virtual void deleteFolder(); + virtual bool deleteFolder(); virtual void downloadMails(); IMAPviewItem *imap; }; class MHviewItem : public AccountViewItem { friend class MHfolderItem; public: MHviewItem( const QString&aMboxPath, AccountView *parent ); virtual ~MHviewItem(); virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail ); AbstractMail *getWrapper(); - virtual QPopupMenu * getContextMenu(); - virtual void contextMenuSelected(int); + virtual bool contextMenuSelected(int); QStringList subFolders(); virtual void refresh(bool force=false); virtual int isServer()const{return 3;} + virtual QMap<int,QString> serverMenu(); + virtual QMap<int,QString> folderMenu(); protected: void downloadMails(); virtual void createFolder(); QString m_Path; AbstractMail *wrapper; QStringList currentFolders; }; @@ -203,23 +207,23 @@ class MHfolderItem : public AccountViewItem { public: MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHviewItem *parent , QListViewItem*after ); MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); virtual ~MHfolderItem(); virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&); virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); - virtual QPopupMenu * getContextMenu(); - virtual void contextMenuSelected(int); + virtual bool contextMenuSelected(int); virtual const Opie::Core::OSmartPointer<Folder>&getFolder()const; virtual bool isDraftfolder(); virtual int isServer()const{return 2;} + virtual QMap<int,QString> folderMenu(); protected: void downloadMails(); virtual void createFolder(); - virtual void deleteFolder(); + virtual bool deleteFolder(); void initName(); MHviewItem *mbox; }; #endif diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index faa42c3..1183704 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -36,47 +36,66 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) AccountView::~AccountView() { imapAccounts.clear(); mhAccounts.clear(); } void AccountView::slotSelectionChanged(QListViewItem*item) { - odebug << "AccountView: Selection changed" << oendl; if (!item) { emit serverSelected(0); return; } AccountViewItem *view = static_cast<AccountViewItem *>(item); - emit serverSelected(view->isServer()); } +QMap<int,QString> AccountView::currentServerMenu()const +{ + QMap<int,QString> smap; + AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); + if (!view)return smap; + smap = view->serverMenu(); + return smap; +} + +QMap<int,QString> AccountView::currentFolderMenu()const +{ + QMap<int,QString> fmap; + AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); + if (!view)return fmap; + fmap = view->folderMenu(); + return fmap; +} + void AccountView::slotContextMenu(int id) { AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); if (!view) return; - view->contextMenuSelected(id); + bool del = view->contextMenuSelected(id); + if (!del && view->isServer()!=2) { + emit refreshMenues(view->isServer()); + } } -void AccountView::slotRightButton(int button, QListViewItem * item,const QPoint&,int) +void AccountView::slotRightButton(int, QListViewItem * item,const QPoint&,int) { m_rightPressed = true; if (!item) return; AccountViewItem *view = static_cast<AccountViewItem *>(item); QPopupMenu*m = view->getContextMenu(); if (!m) return; connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); delete m; } -void AccountView::slotLeftButton(int button, QListViewItem * item,const QPoint&,int) +void AccountView::slotLeftButton(int, QListViewItem *,const QPoint&,int) { m_rightPressed = false; } void AccountView::slotMouseClicked(QListViewItem*item) { if (m_rightPressed) return; if (!item || m_currentItem == item) return; diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index ae24dce..5c4b559 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h @@ -1,15 +1,16 @@ #ifndef ACCOUNTVIEW_H #define ACCOUNTVIEW_H +#include <libmailwrapper/mailtypes.h> +#include <opie2/osmartpointer.h> #include <qlistview.h> #include <qlist.h> -#include <opie2/osmartpointer.h> -#include <libmailwrapper/mailtypes.h> +#include <qmap.h> class Selectstore; class Folder; class AbstractMail; class Account; class IMAPviewItem; class MHviewItem; @@ -19,28 +20,31 @@ class AccountView : public QListView public: AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); virtual ~AccountView(); virtual void populate( QList<Account> list ); virtual RecBodyP fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail); virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper); virtual bool currentisDraft(); + QMap<int,QString> currentServerMenu()const; + QMap<int,QString> currentFolderMenu()const; public slots: virtual void refreshAll(); virtual void refresh(QListViewItem *item); virtual void refreshCurrent(); virtual void slotContextMenu(int id); void setupFolderselect(Selectstore*sels); signals: void refreshMailview(const QValueList<RecMailP>& ); void serverSelected(int); + void refreshMenues(int); protected: QListViewItem* m_currentItem; QValueList<IMAPviewItem*> imapAccounts; QValueList<MHviewItem*> mhAccounts; bool m_rightPressed:1; protected slots: diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 81c8fee..3689352 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp @@ -16,43 +16,48 @@ using namespace Opie::Core; MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) : QMainWindow( parent, name, flags ) { setCaption( tr( "Mail" ) ); setToolBarsMovable( false ); toolBar = new QToolBar( this ); - menuBar = new QMenuBar( toolBar ); mailMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Mail" ), mailMenu ); settingsMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Settings" ), settingsMenu ); - serverMenu = new QPopupMenu( menuBar ); - m_ServerMenuId = menuBar->insertItem( tr( "Server" ), serverMenu ); + if (QApplication::desktop()->width()<330) { + serverMenu = new QPopupMenu( mailMenu ); + folderMenu = new QPopupMenu( mailMenu ); + m_ServerMenuId = mailMenu->insertItem( tr( "Server" ), serverMenu ); + m_FolderMenuId = mailMenu->insertItem( tr( "Folder" ), folderMenu ); + } else { + serverMenu = new QPopupMenu( menuBar ); + folderMenu = new QPopupMenu( menuBar ); + m_FolderMenuId = menuBar->insertItem( tr( "Folder" ), folderMenu ); + m_ServerMenuId = menuBar->insertItem( tr( "Server" ), serverMenu ); + } serverMenu->insertItem(tr("Disconnect"),SERVER_MENU_DISCONNECT); serverMenu->insertItem(tr("Set on/offline"),SERVER_MENU_OFFLINE); serverMenu->insertSeparator(); serverMenu->insertItem(tr("Refresh folder list"),SERVER_MENU_REFRESH_FOLDER); serverMenu->insertItem(tr("Create new folder"),SERVER_MENU_CREATE_FOLDER); serverMenu->insertSeparator(); serverMenu->insertItem(tr("(Un-)Subscribe groups"),SERVER_MENU_SUBSCRIBE); - folderMenu = new QPopupMenu( menuBar ); - m_FolderMenuId = menuBar->insertItem( tr( "Folder" ), folderMenu ); folderMenu->insertItem(tr("Refresh headerlist"),FOLDER_MENU_REFRESH_HEADER); folderMenu->insertItem(tr("Delete all mails"),FOLDER_MENU_DELETE_ALL_MAILS); folderMenu->insertItem(tr("New subfolder"),FOLDER_MENU_NEW_SUBFOLDER); folderMenu->insertItem(tr("Delete folder"),FOLDER_MENU_DELETE_FOLDER); folderMenu->insertItem(tr("Move/Copie all mails"),FOLDER_MENU_MOVE_MAILS); - menuBar->setItemEnabled(m_ServerMenuId,false); menuBar->setItemEnabled(m_FolderMenuId,false); addToolBar( toolBar ); toolBar->setHorizontalStretchable( true ); QLabel *spacer = new QLabel( toolBar ); spacer->setBackgroundMode( QWidget::PaletteButton ); @@ -168,21 +173,19 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) QTimer::singleShot( 10, this, SLOT( slotAdjustColumns() ) ); } MainWindow::~MainWindow() { } -void MainWindow::serverSelected(int m_isFolder) +void MainWindow::serverSelected(int) { - mailView->clear(); - menuBar->setItemEnabled(m_ServerMenuId,m_isFolder&1); - menuBar->setItemEnabled(m_FolderMenuId,m_isFolder&2); + odebug << "slotShowFolders not reached" << oendl; } void MainWindow::systemMessage( const QCString& msg, const QByteArray& data ) { int _newrotation; QDataStream stream( data, IO_ReadOnly ); if ( msg == "setCurrentRotation(int)" ) { diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index 409f160..b781d62 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h @@ -1,22 +1,22 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include "accountview.h" +#include <libmailwrapper/mailtypes.h> + +#include <opie2/osmartpointer.h> + #include <qmainwindow.h> #include <qlistview.h> #include <qaction.h> - #include <qtoolbar.h> #include <qmenubar.h> - -#include "accountview.h" - -#include <libmailwrapper/mailtypes.h> -#include <opie2/osmartpointer.h> +#include <qmap.h> class RecMail; class QCopChannel; class MainWindow : public QMainWindow { Q_OBJECT diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 7c6d314..1bc81e4 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp @@ -103,16 +103,17 @@ void ValueExplode::splitit() } OpieMail::OpieMail( QWidget *parent, const char *name, WFlags ) : MainWindow( parent, name, WStyle_ContextHelp ) { setup_signalblocking(); settings = new Settings(); folderView->populate( settings->getAccounts() ); + connect(folderView,SIGNAL(refreshMenues(int)),this,SLOT(refreshMenu(int))); } OpieMail::~OpieMail() { if (settings) delete settings; } void OpieMail::setup_signalblocking() @@ -381,8 +382,48 @@ void OpieMail::reEditMail() { if (!mailView->currentItem()) return; ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); compose.slotAdjustColumns(); QPEApplication::execDialog( &compose ); } + +void OpieMail::refreshMenu(int m_isFolder) +{ + if (QApplication::desktop()->width()<330) { + mailMenu->setItemEnabled(m_ServerMenuId,m_isFolder&1); + mailMenu->setItemEnabled(m_FolderMenuId,m_isFolder&2); + } else { + menuBar->setItemEnabled(m_ServerMenuId,m_isFolder&1); + menuBar->setItemEnabled(m_FolderMenuId,m_isFolder&2); + } + + QMap<int,QString>::ConstIterator it; + QMap<int,QString> server_entries=folderView->currentServerMenu(); + QMap<int,QString> folder_entries=folderView->currentFolderMenu(); + + int id; + unsigned int i; + for (i=0; i<folderMenu->count();++i) { + id = folderMenu->idAt(i); + folderMenu->setItemEnabled(id,false); + } + for (it=folder_entries.begin();it!=folder_entries.end();++it) { + folderMenu->changeItem(it.key(),it.data()); + folderMenu->setItemEnabled(it.key(),true); + } + for (i=0; i<serverMenu->count();++i) { + id = serverMenu->idAt(i); + serverMenu->setItemEnabled(id,false); + } + for (it=server_entries.begin();it!=server_entries.end();++it) { + serverMenu->changeItem(it.key(),it.data()); + serverMenu->setItemEnabled(it.key(),true); + } +} + +void OpieMail::serverSelected(int m_isFolder) +{ + mailView->clear(); + refreshMenu(m_isFolder); +} diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h index c9d758d..75a0b2d 100644 --- a/noncore/net/mail/opiemail.h +++ b/noncore/net/mail/opiemail.h @@ -1,45 +1,49 @@ #ifndef OPIEMAIL_H #define OPIEMAIL_H #include "mainwindow.h" #include <libmailwrapper/settings.h> +#include <libmailwrapper/mailtypes.h> #include <opie2/osmartpointer.h> -#include <libmailwrapper/mailtypes.h> + +#include <qmap.h> class OpieMail : public MainWindow { Q_OBJECT public: OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); virtual ~OpieMail(); static QString appName() { return QString::fromLatin1("opiemail"); } public slots: virtual void slotwriteMail(const QString&name,const QString&email); virtual void slotComposeMail(); virtual void appMessage(const QCString &msg, const QByteArray &data); void setDocument(const QString&); - + protected slots: virtual void slotSendQueued(); virtual void slotSearchMails(); virtual void slotEditSettings(); virtual void slotEditAccounts(); virtual void displayMail(); virtual void slotDeleteMail(); virtual void mailHold(int, QListViewItem *,const QPoint&,int); virtual void slotShowFolders( bool show ); virtual void refreshMailView(const QValueList<RecMailP>&); virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); virtual void slotMoveCopyMail(); virtual void reEditMail(); + virtual void serverSelected(int); + virtual void refreshMenu(int); protected: void setup_signalblocking(); private: Settings *settings; }; |