summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-12 22:14:03 (UTC)
committer alwin <alwin>2005-03-12 22:14:03 (UTC)
commit3cb4c3983ee738f3221ecb4cb154ea1252d69d64 (patch) (side-by-side diff)
tree13357c046fd618b10546ad6d21992826eab3ad01
parent9dddeb81d7db5da718f3f467bb1511b7e72b9caa (diff)
downloadopie-3cb4c3983ee738f3221ecb4cb154ea1252d69d64.zip
opie-3cb4c3983ee738f3221ecb4cb154ea1252d69d64.tar.gz
opie-3cb4c3983ee738f3221ecb4cb154ea1252d69d64.tar.bz2
rework of the structure of the main menues, them depends now on state of current selected folder/server
on small screens some "Folder" and "Server" menu will get submenus of the menu-item "Mail" cause lack of space on screen - have no other idea.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountitem.cpp240
-rw-r--r--noncore/net/mail/accountitem.h50
-rw-r--r--noncore/net/mail/accountview.cpp29
-rw-r--r--noncore/net/mail/accountview.h8
-rw-r--r--noncore/net/mail/mainwindow.cpp23
-rw-r--r--noncore/net/mail/mainwindow.h12
-rw-r--r--noncore/net/mail/opiemail.cpp41
-rw-r--r--noncore/net/mail/opiemail.h8
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
@@ -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()
+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;
}
@@ -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()
+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;
}
@@ -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()
+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;
}
@@ -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;
+}
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
@@ -2,7 +2,9 @@
#define __ACCOUNT_ITEM
+#include <opie2/osmartpointer.h>
+
#include <qlistview.h>
#include <qlist.h>
-#include <opie2/osmartpointer.h>
+#include <qmap.h>
class POP3wrapper;
@@ -32,6 +34,6 @@ public:
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;
@@ -39,7 +41,9 @@ public:
/* 1 - server
* 2 - folder
- * 3 - beides
+ * 3 - both
*/
virtual int isServer()const=0;
+ virtual QMap<int,QString> serverMenu();
+ virtual QMap<int,QString> folderMenu();
protected:
@@ -62,7 +66,7 @@ public:
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:
@@ -82,7 +86,7 @@ public:
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:
@@ -101,7 +105,7 @@ public:
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:
@@ -122,8 +126,7 @@ public:
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();
@@ -142,10 +145,10 @@ public:
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:
@@ -165,11 +168,11 @@ public:
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;
@@ -186,9 +189,10 @@ public:
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:
@@ -209,14 +213,14 @@ public:
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;
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
@@ -42,5 +42,4 @@ AccountView::~AccountView()
void AccountView::slotSelectionChanged(QListViewItem*item)
{
- odebug << "AccountView: Selection changed" << oendl;
if (!item) {
emit serverSelected(0);
@@ -48,16 +47,36 @@ void AccountView::slotSelectionChanged(QListViewItem*item)
}
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;
@@ -72,5 +91,5 @@ void AccountView::slotRightButton(int button, QListViewItem * item,const QPoint&
}
-void AccountView::slotLeftButton(int button, QListViewItem * item,const QPoint&,int)
+void AccountView::slotLeftButton(int, QListViewItem *,const QPoint&,int)
{
m_rightPressed = false;
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
@@ -2,8 +2,9 @@
#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;
@@ -25,4 +26,6 @@ public:
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:
@@ -37,4 +40,5 @@ signals:
void refreshMailview(const QValueList<RecMailP>& );
void serverSelected(int);
+ void refreshMenues(int);
protected:
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
@@ -22,5 +22,4 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
toolBar = new QToolBar( this );
-
menuBar = new QMenuBar( toolBar );
@@ -31,6 +30,15 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
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);
@@ -41,6 +49,4 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
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);
@@ -48,5 +54,4 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
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);
@@ -174,9 +179,7 @@ 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;
}
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
@@ -2,15 +2,15 @@
#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;
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
@@ -109,4 +109,5 @@ OpieMail::OpieMail( QWidget *parent, const char *name, WFlags )
settings = new Settings();
folderView->populate( settings->getAccounts() );
+ connect(folderView,SIGNAL(refreshMenues(int)),this,SLOT(refreshMenu(int)));
}
@@ -387,2 +388,42 @@ void OpieMail::reEditMail()
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
@@ -4,7 +4,9 @@
#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
@@ -22,5 +24,5 @@ public slots:
virtual void appMessage(const QCString &msg, const QByteArray &data);
void setDocument(const QString&);
-
+
protected slots:
virtual void slotSendQueued();
@@ -36,4 +38,6 @@ protected slots:
virtual void slotMoveCopyMail();
virtual void reEditMail();
+ virtual void serverSelected(int);
+ virtual void refreshMenu(int);
protected: