-rw-r--r-- | noncore/net/mail/accountitem.cpp | 155 | ||||
-rw-r--r-- | noncore/net/mail/accountitem.h | 13 | ||||
-rw-r--r-- | noncore/net/mail/accountview.cpp | 52 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 11 | ||||
-rw-r--r-- | noncore/net/mail/defines.h | 27 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 35 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 5 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 4 |
8 files changed, 217 insertions, 85 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index c1574fd..4869df8 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp @@ -79,7 +79,7 @@ void POP3viewItem::refresh() RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) { - odebug << "POP3 fetchBody" << oendl; + odebug << "POP3 fetchBody" << oendl; return wrapper->fetchBody( mail ); } @@ -90,12 +90,12 @@ QPopupMenu * POP3viewItem::getContextMenu() { if (!account->getOffline()) { - m->insertItem(QObject::tr("Disconnect",contextName),0); - m->insertItem(QObject::tr("Set offline",contextName),1); + 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),1); + m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); } } return m; @@ -129,10 +129,10 @@ void POP3viewItem::contextMenuSelected(int which) { switch (which) { - case 0: + case SERVER_MENU_DISCONNECT: disconnect(); break; - case 1: + case SERVER_MENU_OFFLINE: setOnOffline(); break; } @@ -172,9 +172,9 @@ QPopupMenu * POP3folderItem::getContextMenu() QPopupMenu *m = new QPopupMenu(0); if (m) { - m->insertItem(QObject::tr("Refresh header list",contextName),0); - m->insertItem(QObject::tr("Delete all mails",contextName),1); - m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); + 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; } @@ -191,15 +191,15 @@ void POP3folderItem::contextMenuSelected(int which) AccountView * view = (AccountView*)listView(); switch (which) { - case 0: + case FOLDER_MENU_REFRESH_HEADER: /* must be 'cause pop3 lists are cached */ pop3->getWrapper()->logout(); view->refreshCurrent(); break; - case 1: + case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(pop3->getWrapper(),folder); break; - case 2: + case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; default: @@ -270,7 +270,7 @@ void NNTPviewItem::refresh() RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) { - odebug << "NNTP fetchBody" << oendl; + odebug << "NNTP fetchBody" << oendl; return wrapper->fetchBody( mail ); } @@ -281,13 +281,13 @@ QPopupMenu * NNTPviewItem::getContextMenu() { if (!account->getOffline()) { - m->insertItem(QObject::tr("Disconnect",contextName),0); - m->insertItem(QObject::tr("Set offline",contextName),1); - m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); + 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),1); + m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); } } return m; @@ -330,13 +330,13 @@ void NNTPviewItem::contextMenuSelected(int which) { switch (which) { - case 0: + case SERVER_MENU_DISCONNECT: disconnect(); break; - case 1: + case SERVER_MENU_OFFLINE: setOnOffline(); break; - case 2: + case SERVER_MENU_SUBSCRIBE: subscribeGroups(); break; } @@ -376,8 +376,8 @@ QPopupMenu * NNTPfolderItem::getContextMenu() QPopupMenu *m = new QPopupMenu(0); if (m) { - m->insertItem(QObject::tr("Refresh header list",contextName),0); - m->insertItem(QObject::tr("Copy all postings",contextName),1); + 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; } @@ -394,12 +394,12 @@ void NNTPfolderItem::contextMenuSelected(int which) AccountView * view = (AccountView*)listView(); switch (which) { - case 0: - /* must be 'cause pop3 lists are cached */ + case FOLDER_MENU_REFRESH_HEADER: + /* must be 'cause nntp lists are cached */ nntp->getWrapper()->logout(); view->refreshCurrent(); break; - case 1: + case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; default: @@ -461,7 +461,7 @@ void IMAPviewItem::refreshFolders(bool force) { item = new IMAPfolderItem( (*it), this , item ); folders->remove(it); - odebug << "inbox found" << oendl; + odebug << "inbox found" << oendl; break; } } @@ -498,15 +498,15 @@ QPopupMenu * IMAPviewItem::getContextMenu() { if (!account->getOffline()) { - m->insertItem(QObject::tr("Refresh folder list",contextName),0); - m->insertItem(QObject::tr("Create new folder",contextName),1); + 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("Disconnect",contextName),2); - m->insertItem(QObject::tr("Set offline",contextName),3); + 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),3); + m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); } } return m; @@ -534,20 +534,20 @@ void IMAPviewItem::createNewFolder() void IMAPviewItem::contextMenuSelected(int id) { - odebug << "Id selected: " << id << "" << oendl; + odebug << "Id selected: " << id << "" << oendl; switch (id) { - case 0: + case SERVER_MENU_REFRESH_FOLDER: refreshFolders(true); break; - case 1: + case SERVER_MENU_CREATE_FOLDER: createNewFolder(); break; - case 2: + case SERVER_MENU_DISCONNECT: removeChilds(); wrapper->logout(); break; - case 3: + case SERVER_MENU_OFFLINE: if (account->getOffline()==false) { removeChilds(); @@ -635,17 +635,17 @@ QPopupMenu * IMAPfolderItem::getContextMenu() { if (folder->may_select()) { - m->insertItem(QObject::tr("Refresh header list",contextName),0); - m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); - m->insertItem(QObject::tr("Delete all mails",contextName),1); + 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),2); + m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); } if (folder->getDisplayName().lower()!="inbox") { - m->insertItem(QObject::tr("Delete folder",contextName),3); + m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); } } return m; @@ -672,7 +672,7 @@ void IMAPfolderItem::deleteFolder() 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; + odebug << "Auswahl: " << yesno << "" << oendl; if (yesno == 0) { if (imap->getWrapper()->deleteMbox(folder)) @@ -699,23 +699,27 @@ void IMAPfolderItem::downloadMails() void IMAPfolderItem::contextMenuSelected(int id) { - odebug << "Selected id: " << id << "" << oendl; + odebug << "Selected id: " << id << "" << oendl; AccountView * view = (AccountView*)listView(); switch(id) { - case 0: + case FOLDER_MENU_REFRESH_HEADER: view->refreshCurrent(); break; - case 1: + case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(imap->getWrapper(),folder); break; - case 2: - createNewFolder(); + case FOLDER_MENU_NEW_SUBFOLDER: + if (folder->no_inferior()==false) { + createNewFolder(); + } break; - case 3: - deleteFolder(); + case FOLDER_MENU_DELETE_FOLDER: + if (folder->getDisplayName().lower()!="inbox") { + deleteFolder(); + } break; - case 4: + case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; default: @@ -759,6 +763,7 @@ void MHviewItem::refresh( QValueList<RecMailP> & target) void MHviewItem::refresh(bool force) { if (childCount()>0 && force==false) return; + odebug << "Refresh mh folders" << oendl; removeChilds(); currentFolders.clear(); QValueList<FolderP> *folders = wrapper->listFolders(); @@ -803,7 +808,7 @@ void MHviewItem::refresh(bool force) RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) { - odebug << "MH fetchBody" << oendl; + odebug << "MH fetchBody" << oendl; return wrapper->fetchBody( mail ); } @@ -812,10 +817,10 @@ QPopupMenu * MHviewItem::getContextMenu() QPopupMenu *m = new QPopupMenu(0); if (m) { - m->insertItem(QObject::tr("Refresh folder list",contextName),0); - m->insertItem(QObject::tr("Create new folder",contextName),1); - m->insertItem(QObject::tr("Delete all mails",contextName),2); - m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); + 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; } @@ -847,20 +852,26 @@ QStringList MHviewItem::subFolders() void MHviewItem::contextMenuSelected(int which) { + AccountView*view = 0; + switch (which) { - case 0: + case SERVER_MENU_REFRESH_FOLDER: refresh(true); break; - case 1: + case FOLDER_MENU_NEW_SUBFOLDER: createFolder(); break; - case 2: + case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(getWrapper(),folder); break; - case 3: + case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; + case FOLDER_MENU_REFRESH_HEADER: + view = (AccountView*)listView(); + if (view) view->refreshCurrent(); + break; default: break; } @@ -933,7 +944,7 @@ void MHfolderItem::deleteFolder() 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; + odebug << "Auswahl: " << yesno << "" << oendl; if (yesno == 0) { if (mbox->getWrapper()->deleteMbox(folder)) @@ -956,10 +967,11 @@ QPopupMenu * MHfolderItem::getContextMenu() QPopupMenu *m = new QPopupMenu(0); if (m) { - m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); - m->insertItem(QObject::tr("Delete all mails",contextName),0); - m->insertItem(QObject::tr("Create new subfolder",contextName),3); - m->insertItem(QObject::tr("Delete folder",contextName),1); + 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; } @@ -994,20 +1006,25 @@ void MHfolderItem::createFolder() void MHfolderItem::contextMenuSelected(int which) { + AccountView*view = 0; switch(which) { - case 0: + case FOLDER_MENU_DELETE_ALL_MAILS: deleteAllMail(mbox->getWrapper(),folder); break; - case 1: + case FOLDER_MENU_DELETE_FOLDER: deleteFolder(); break; - case 2: + case FOLDER_MENU_MOVE_MAILS: downloadMails(); break; - case 3: + case FOLDER_MENU_NEW_SUBFOLDER: createFolder(); break; + case FOLDER_MENU_REFRESH_HEADER: + view = (AccountView*)listView(); + if (view) view->refreshCurrent(); + break; default: break; } @@ -1075,7 +1092,7 @@ void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) arg(fname), QObject::tr("Yes",contextName), QObject::tr("No",contextName),QString::null,1,1); - odebug << "Auswahl: " << yesno << "" << oendl; + odebug << "Auswahl: " << yesno << "" << oendl; if (yesno == 0) { if (wrapper->deleteAllMail(folder)) diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h index f125eeb..b2c50a1 100644 --- a/noncore/net/mail/accountitem.h +++ b/noncore/net/mail/accountitem.h @@ -36,6 +36,11 @@ public: virtual AccountView*accountView(); virtual bool matchName(const QString&name)const; virtual bool isDraftfolder(); + /* 1 - server + * 2 - folder + * 3 - beides + */ + virtual int isServer()const=0; protected: AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); @@ -58,6 +63,7 @@ public: AbstractMail *getWrapper(); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); + virtual int isServer()const{return 1;} protected: POP3account *account; @@ -77,6 +83,7 @@ public: virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); + virtual int isServer()const{return 2;} protected: void downloadMails(); @@ -95,6 +102,7 @@ public: AbstractMail *getWrapper(); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); + virtual int isServer()const{return 1;} protected: NNTPaccount *account; @@ -115,6 +123,7 @@ public: virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); + virtual int isServer()const{return 2;} protected: void downloadMails(); @@ -136,6 +145,7 @@ public: virtual void contextMenuSelected(int); const QStringList&subFolders(); virtual void refreshFolders(bool force=false); + virtual int isServer()const{return 1;} bool offline(); protected: @@ -157,6 +167,7 @@ public: virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); virtual const QString& Delemiter()const; + virtual int isServer()const{return 2;} protected: virtual void createNewFolder(); virtual void deleteFolder(); @@ -178,6 +189,7 @@ public: virtual void contextMenuSelected(int); QStringList subFolders(); virtual void refresh(bool force=false); + virtual int isServer()const{return 3;} protected: void downloadMails(); @@ -200,6 +212,7 @@ public: virtual void contextMenuSelected(int); virtual const Opie::Core::OSmartPointer<Folder>&getFolder()const; virtual bool isDraftfolder(); + virtual int isServer()const{return 2;} protected: void downloadMails(); diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index c747a8b..d01d6bb 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -20,11 +20,17 @@ using namespace Opie::Core; AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) : QListView( parent, name, flags ) { + setSorting(0); + setSelectionMode(Single); + m_rightPressed = false; + connect( this, SIGNAL( selectionChanged(QListViewItem*) ), - SLOT( refresh(QListViewItem*) ) ); + SLOT( slotSelectionChanged(QListViewItem*) ) ); connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, - SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); - setSorting(0); + SLOT( slotMouseButton(int,QListViewItem*,const QPoint&,int) ) ); + connect( this, SIGNAL(clicked(QListViewItem*) ),this, + SLOT( slotMouseClicked(QListViewItem*) ) ); + m_currentItem = 0; } AccountView::~AccountView() @@ -33,6 +39,18 @@ AccountView::~AccountView() 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()); +} + void AccountView::slotContextMenu(int id) { AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); @@ -40,9 +58,9 @@ void AccountView::slotContextMenu(int id) view->contextMenuSelected(id); } -void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) +void AccountView::slotRightButton(int button, QListViewItem * item,const QPoint&,int) { - if (button==1) {return;} + m_rightPressed = true; if (!item) return; AccountViewItem *view = static_cast<AccountViewItem *>(item); QPopupMenu*m = view->getContextMenu(); @@ -51,6 +69,30 @@ void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); delete m; + setSelected(item,true); +} + +void AccountView::slotLeftButton(int button, QListViewItem * item,const QPoint&,int) +{ + m_rightPressed = false; +} + +void AccountView::slotMouseClicked(QListViewItem*item) +{ + if (m_rightPressed) return; + if (!item || m_currentItem == item) return; + /* ### ToDo check settings if on single tab it should open */ + m_currentItem = item; + refresh(m_currentItem); +} + +void AccountView::slotMouseButton(int button, QListViewItem * item,const QPoint&pos,int column) +{ + if (button==1) { + slotLeftButton(button,item,pos,column); + } else if (button==2) { + slotRightButton(button,item,pos,column); + } } void AccountView::populate( QList<Account> list ) diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 787b0b0..ae24dce 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h @@ -29,17 +29,26 @@ public slots: virtual void refreshAll(); virtual void refresh(QListViewItem *item); virtual void refreshCurrent(); - virtual void slotHold(int, QListViewItem *,const QPoint&,int); virtual void slotContextMenu(int id); + void setupFolderselect(Selectstore*sels); signals: void refreshMailview(const QValueList<RecMailP>& ); + void serverSelected(int); protected: QListViewItem* m_currentItem; QValueList<IMAPviewItem*> imapAccounts; QValueList<MHviewItem*> mhAccounts; + bool m_rightPressed:1; + +protected slots: + virtual void slotRightButton(int, QListViewItem *,const QPoint&,int); + virtual void slotLeftButton(int, QListViewItem *,const QPoint&,int); + virtual void slotMouseButton(int, QListViewItem *,const QPoint&,int); + virtual void slotMouseClicked(QListViewItem*); + virtual void slotSelectionChanged(QListViewItem*); }; #endif diff --git a/noncore/net/mail/defines.h b/noncore/net/mail/defines.h index d840f09..5fcbf0f 100644 --- a/noncore/net/mail/defines.h +++ b/noncore/net/mail/defines.h @@ -18,13 +18,13 @@ #define PIC_OFFLINE "mail/notconnected" -#define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) -#define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) -#define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) -#define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) -#define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) -#define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) -#define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) +#define ICON_COMPOSEMAIL QIconSet( Resource::loadPixmap( PIC_COMPOSEMAIL ) ) +#define ICON_SENDQUEUED QIconSet( Resource::loadPixmap( PIC_SENDQUEUED ) ) +#define ICON_SHOWFOLDERS QIconSet( Resource::loadPixmap( PIC_SHOWFOLDERS ) ) +#define ICON_SEARCHMAILS QIconSet( Resource::loadPixmap( PIC_SEARCHMAILS ) ) +#define ICON_EDITSETTINGS QIconSet( Resource::loadPixmap( PIC_EDITSETTINGS ) ) +#define ICON_EDITACCOUNTS QIconSet( Resource::loadPixmap( PIC_EDITACCOUNTS ) ) +#define ICON_SYNC QIconSet( Resource::loadPixmap( PIC_SYNC ) ) #define PIXMAP_IMAPFOLDER QPixmap( Resource::loadPixmap( PIC_IMAPFOLDER ) ) #define PIXMAP_POP3FOLDER QPixmap( Resource::loadPixmap( PIC_POP3FOLDER ) ) @@ -54,4 +54,17 @@ #define UTF16LOSTART 0xDC00UL #define UTF16LOEND 0xDFFFUL +/* used for making menuids transparent */ +#define FOLDER_MENU_REFRESH_HEADER 0 +#define FOLDER_MENU_DELETE_ALL_MAILS 1 +#define FOLDER_MENU_NEW_SUBFOLDER 2 +#define FOLDER_MENU_DELETE_FOLDER 3 +#define FOLDER_MENU_MOVE_MAILS 4 + +#define SERVER_MENU_DISCONNECT 5 +#define SERVER_MENU_OFFLINE 6 +#define SERVER_MENU_REFRESH_FOLDER 7 +#define SERVER_MENU_CREATE_FOLDER 8 +#define SERVER_MENU_SUBSCRIBE 9 + #endif diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 0a45445..81c8fee 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp @@ -21,12 +21,36 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 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 ); + 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 ); @@ -90,6 +114,10 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) folderView->header()->hide(); folderView->setRootIsDecorated( true ); folderView->addColumn( tr( "Mailbox" ) ); + connect(folderView,SIGNAL(serverSelected(int)),this,SLOT(serverSelected(int))); + connect(serverMenu,SIGNAL(activated(int)),folderView,SLOT(slotContextMenu(int))); + connect(folderMenu,SIGNAL(activated(int)),folderView,SLOT(slotContextMenu(int))); + layout->addWidget( folderView ); @@ -145,6 +173,13 @@ MainWindow::~MainWindow() { } +void MainWindow::serverSelected(int m_isFolder) +{ + mailView->clear(); + menuBar->setItemEnabled(m_ServerMenuId,m_isFolder&1); + menuBar->setItemEnabled(m_FolderMenuId,m_isFolder&2); +} + void MainWindow::systemMessage( const QCString& msg, const QByteArray& data ) { int _newrotation; diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index ad71a54..409f160 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h @@ -41,11 +41,13 @@ protected slots: virtual void slotAdjustLayout(); virtual void slotEditSettings(); virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); + virtual void serverSelected(int); protected: QToolBar *toolBar; QMenuBar *menuBar; - QPopupMenu *mailMenu, *settingsMenu; + QPopupMenu *mailMenu, *settingsMenu,*serverMenu,*folderMenu; + QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, *editSettings, *editAccounts, *syncFolders; AccountView *folderView; @@ -53,6 +55,7 @@ protected: QBoxLayout *layout; int m_Rotate; QCopChannel* m_sysChannel; + int m_ServerMenuId,m_FolderMenuId; }; #endif diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 9eba23e..7c6d314 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp @@ -80,8 +80,8 @@ void ValueExplode::splitit() m_LastParsed.append(tkeyvalues(m_Command,"")); return; } - int pos,pos2,startpos; - startpos = 0; + int pos,pos2; + unsigned startpos = 0; iLine = m_Command; while ( (pos = iLine.find(mDelemiter,startpos))!=-1) { pos2 = iLine.find(m2Delemiter,startpos); |