Diffstat (limited to 'noncore/net/mail/accountitem.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/accountitem.cpp | 259 |
1 files changed, 172 insertions, 87 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index 2d3cd4b..c8f6ec4 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp @@ -1,12 +1,18 @@ + #include "accountitem.h" #include "accountview.h" -#include <qpopupmenu.h> -#include <qmessagebox.h> #include "selectstore.h" #include "newmaildir.h" +#include "defines.h" + +/* OPIE */ #include <libmailwrapper/mailtypes.h> #include <libmailwrapper/abstractmail.h> #include <libmailwrapper/mailwrapper.h> -#include "defines.h" +#include <qpe/qpeapplication.h> + +/* QT */ +#include <qpopupmenu.h> +#include <qmessagebox.h> #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} @@ -21,7 +27,10 @@ POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) SETPIX(PIXMAP_POP3FOLDER); #if 0 - if (!account->getOffline()) { + if (!account->getOffline()) + { setPixmap( 0, ); - } else { + } + else + { setPixmap( 0, PIXMAP_OFFLINE ); } @@ -51,5 +60,6 @@ void POP3viewItem::refresh() QList<Folder> *folders = wrapper->listFolders(); QListViewItem *child = firstChild(); - while ( child ) { + while ( child ) + { QListViewItem *tmp = child; child = child->nextSibling(); @@ -58,5 +68,6 @@ void POP3viewItem::refresh() Folder *it; QListViewItem*item = 0; - for ( it = folders->first(); it; it = folders->next() ) { + for ( it = folders->first(); it; it = folders->next() ) + { item = new POP3folderItem( it, this , item ); item->setSelectable(it->may_select()); @@ -76,9 +87,13 @@ QPopupMenu * POP3viewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { - if (!account->getOffline()) { + if (m) + { + if (!account->getOffline()) + { m->insertItem(QObject::tr("Disconnect",contextName),0); m->insertItem(QObject::tr("Set offline",contextName),1); - } else { + } + else + { m->insertItem(QObject::tr("Set online",contextName),1); } @@ -90,5 +105,6 @@ void POP3viewItem::disconnect() { QListViewItem *child = firstChild(); - while ( child ) { + while ( child ) + { QListViewItem *tmp = child; child = child->nextSibling(); @@ -100,5 +116,6 @@ void POP3viewItem::disconnect() void POP3viewItem::setOnOffline() { - if (!account->getOffline()) { + if (!account->getOffline()) + { disconnect(); } @@ -111,5 +128,6 @@ void POP3viewItem::setOnOffline() void POP3viewItem::contextMenuSelected(int which) { - switch (which) { + switch (which) + { case 0: disconnect(); @@ -122,6 +140,5 @@ void POP3viewItem::contextMenuSelected(int which) POP3folderItem::~POP3folderItem() -{ -} +{} POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) @@ -130,7 +147,10 @@ POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QList folder = folderInit; pop3 = parent; - if (folder->getDisplayName().lower()!="inbox") { + if (folder->getDisplayName().lower()!="inbox") + { setPixmap( 0, PIXMAP_POP3FOLDER ); - } else { + } + else + { setPixmap( 0, PIXMAP_INBOXFOLDER); } @@ -152,5 +172,6 @@ QPopupMenu * POP3folderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { + if (m) + { m->insertItem(QObject::tr("Refresh header list",contextName),0); m->insertItem(QObject::tr("Delete all mails",contextName),1); @@ -170,5 +191,6 @@ void POP3folderItem::contextMenuSelected(int which) { AccountView * view = (AccountView*)listView(); - switch (which) { + switch (which) + { case 0: /* must be 'cause pop3 lists are cached */ @@ -237,6 +259,8 @@ void IMAPviewItem::refreshFolders(bool force) folders->setAutoDelete(false); - for ( it = folders->first(); it; it = folders->next() ) { - if (it->getDisplayName().lower()=="inbox") { + for ( it = folders->first(); it; it = folders->next() ) + { + if (it->getDisplayName().lower()=="inbox") + { item = new IMAPfolderItem( it, this , item ); folders->remove(it); @@ -245,13 +269,16 @@ void IMAPviewItem::refreshFolders(bool force) } } - for ( it = folders->first(); it; it = folders->next() ) { + for ( it = folders->first(); it; it = folders->next() ) + { fname = it->getDisplayName(); currentFolders.append(it->getName()); pos = fname.findRev(it->Separator()); - if (pos != -1) { + if (pos != -1) + { fname = fname.left(pos); } IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); - if (pitem) { + if (pitem) + { titem = item; item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); @@ -259,5 +286,7 @@ void IMAPviewItem::refreshFolders(bool force) item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); item = titem; - } else { + } + else + { item = new IMAPfolderItem( it, this , item ); } @@ -269,6 +298,8 @@ QPopupMenu * IMAPviewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { - if (!account->getOffline()) { + if (m) + { + if (!account->getOffline()) + { m->insertItem(QObject::tr("Refresh folder list",contextName),0); m->insertItem(QObject::tr("Create new folder",contextName),1); @@ -276,5 +307,7 @@ QPopupMenu * IMAPviewItem::getContextMenu() m->insertItem(QObject::tr("Disconnect",contextName),2); m->insertItem(QObject::tr("Set offline",contextName),3); - } else { + } + else + { m->insertItem(QObject::tr("Set online",contextName),3); } @@ -286,14 +319,16 @@ void IMAPviewItem::createNewFolder() { Newmdirdlg ndirdlg; - ndirdlg.showMaximized(); - if (ndirdlg.exec()) { + if ( QPEApplication::execDialog( &ndirdlg )) + { QString ndir = ndirdlg.Newdir(); bool makesubs = ndirdlg.subpossible(); QString delemiter = "/"; IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); - if (item) { + if (item) + { delemiter = item->Delemiter(); } - if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { + if (wrapper->createMbox(ndir,0,delemiter,makesubs)) + { refreshFolders(true); } @@ -304,5 +339,6 @@ void IMAPviewItem::contextMenuSelected(int id) { qDebug("Id selected: %i",id); - switch (id) { + switch (id) + { case 0: refreshFolders(true); @@ -316,5 +352,6 @@ void IMAPviewItem::contextMenuSelected(int id) break; case 3: - if (account->getOffline()==false) { + if (account->getOffline()==false) + { removeChilds(); wrapper->logout(); @@ -345,7 +382,10 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QList folder = folderInit; imap = parent; - if (folder->getDisplayName().lower()!="inbox") { + if (folder->getDisplayName().lower()!="inbox") + { setPixmap( 0, PIXMAP_IMAPFOLDER ); - } else { + } + else + { setPixmap( 0, PIXMAP_INBOXFOLDER); } @@ -358,7 +398,10 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QLi folder = folderInit; imap = master; - if (folder->getDisplayName().lower()!="inbox") { + if (folder->getDisplayName().lower()!="inbox") + { setPixmap( 0, PIXMAP_IMAPFOLDER ); - } else { + } + else + { setPixmap( 0, PIXMAP_INBOXFOLDER); } @@ -367,6 +410,5 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QLi IMAPfolderItem::~IMAPfolderItem() -{ -} +{} const QString& IMAPfolderItem::Delemiter()const @@ -377,7 +419,10 @@ const QString& IMAPfolderItem::Delemiter()const void IMAPfolderItem::refresh(QList<RecMail>&target) { - if (folder->may_select()) { + if (folder->may_select()) + { imap->getWrapper()->listMessages( folder->getName(),target ); - } else { + } + else + { target.clear(); } @@ -392,14 +437,18 @@ QPopupMenu * IMAPfolderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { - if (folder->may_select()) { + if (m) + { + 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); } - if (folder->no_inferior()==false) { + if (folder->no_inferior()==false) + { m->insertItem(QObject::tr("Create new subfolder",contextName),2); } - if (folder->getDisplayName().lower()!="inbox") { + if (folder->getDisplayName().lower()!="inbox") + { m->insertItem(QObject::tr("Delete folder",contextName),3); } @@ -411,10 +460,11 @@ void IMAPfolderItem::createNewFolder() { Newmdirdlg ndirdlg; - ndirdlg.showMaximized(); - if (ndirdlg.exec()) { + if ( QPEApplication::execDialog( &ndirdlg ) ) + { QString ndir = ndirdlg.Newdir(); bool makesubs = ndirdlg.subpossible(); QString delemiter = Delemiter(); - if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { + if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) + { imap->refreshFolders(true); } @@ -429,6 +479,8 @@ void IMAPfolderItem::deleteFolder() QObject::tr("No",contextName),QString::null,1,1); qDebug("Auswahl: %i",yesno); - if (yesno == 0) { - if (imap->getWrapper()->deleteMbox(folder)) { + if (yesno == 0) + { + if (imap->getWrapper()->deleteMbox(folder)) + { QListView*v=listView(); IMAPviewItem * box = imap; @@ -436,5 +488,6 @@ void IMAPfolderItem::deleteFolder() * any member of it after that call!!*/ imap->refreshFolders(true); - if (v) { + if (v) + { v->setSelected(box,true); } @@ -454,5 +507,6 @@ void IMAPfolderItem::contextMenuSelected(int id) qDebug("Selected id: %i",id); AccountView * view = (AccountView*)listView(); - switch(id) { + switch(id) + { case 0: view->refreshCurrent(); @@ -519,8 +573,10 @@ void MHviewItem::refresh(bool force) QString fname = ""; int pos; - for ( it = folders->first(); it; it = folders->next() ) { + for ( it = folders->first(); it; it = folders->next() ) + { fname = it->getDisplayName(); /* this folder itself */ - if (fname=="/") { + if (fname=="/") + { currentFolders.append(fname); folder = it; @@ -529,13 +585,19 @@ void MHviewItem::refresh(bool force) currentFolders.append(fname); pos = fname.findRev("/"); - if (pos > 0) { + if (pos > 0) + { fname = fname.left(pos); pmaster = (MHfolderItem*)findSubItem(fname); - } else { + } + else + { pmaster = 0; } - if (pmaster) { + if (pmaster) + { item = new MHfolderItem( it, pmaster, item, this ); - } else { + } + else + { item = new MHfolderItem( it, this , item ); } @@ -556,5 +618,6 @@ QPopupMenu * MHviewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { + if (m) + { m->insertItem(QObject::tr("Refresh folder list",contextName),0); m->insertItem(QObject::tr("Create new folder",contextName),1); @@ -568,8 +631,9 @@ void MHviewItem::createFolder() { Newmdirdlg ndirdlg(0,0,true); - ndirdlg.showMaximized(); - if (ndirdlg.exec()) { + if ( QPEApplication::execDialog( &ndirdlg ) ) + { QString ndir = ndirdlg.Newdir(); - if (wrapper->createMbox(ndir)) { + if (wrapper->createMbox(ndir)) + { refresh(true); } @@ -591,5 +655,6 @@ QStringList MHviewItem::subFolders() void MHviewItem::contextMenuSelected(int which) { - switch (which) { + switch (which) + { case 0: refresh(true); @@ -610,6 +675,5 @@ void MHviewItem::contextMenuSelected(int which) MHfolderItem::~MHfolderItem() -{ -} +{} MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after ) @@ -632,16 +696,23 @@ void MHfolderItem::initName() { QString bName = folder->getDisplayName(); - if (bName.startsWith("/")&&bName.length()>1) { + if (bName.startsWith("/")&&bName.length()>1) + { bName.replace(0,1,""); } int pos = bName.findRev("/"); - if (pos > 0) { + if (pos > 0) + { bName.replace(0,pos+1,""); } - if (bName.lower() == "outgoing") { + if (bName.lower() == "outgoing") + { setPixmap( 0, PIXMAP_OUTBOXFOLDER ); - } else if (bName.lower() == "inbox") { + } + else if (bName.lower() == "inbox") + { setPixmap( 0, PIXMAP_INBOXFOLDER); - } else { + } + else + { setPixmap( 0, PIXMAP_MBOXFOLDER ); } @@ -672,6 +743,8 @@ void MHfolderItem::deleteFolder() QObject::tr("No",contextName),QString::null,1,1); qDebug("Auswahl: %i",yesno); - if (yesno == 0) { - if (mbox->getWrapper()->deleteMbox(folder)) { + if (yesno == 0) + { + if (mbox->getWrapper()->deleteMbox(folder)) + { QListView*v=listView(); MHviewItem * box = mbox; @@ -679,5 +752,6 @@ void MHfolderItem::deleteFolder() * any member of it after that call!!*/ mbox->refresh(true); - if (v) { + if (v) + { v->setSelected(box,true); } @@ -689,5 +763,6 @@ QPopupMenu * MHfolderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); - if (m) { + if (m) + { m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); m->insertItem(QObject::tr("Delete all mails",contextName),0); @@ -708,8 +783,9 @@ void MHfolderItem::createFolder() { Newmdirdlg ndirdlg(0,0,true); - ndirdlg.showMaximized(); - if (ndirdlg.exec()) { + if ( QPEApplication::execDialog( &ndirdlg ) ) + { QString ndir = ndirdlg.Newdir(); - if (mbox->getWrapper()->createMbox(ndir,folder)) { + if (mbox->getWrapper()->createMbox(ndir,folder)) + { QListView*v=listView(); MHviewItem * box = mbox; @@ -717,5 +793,6 @@ void MHfolderItem::createFolder() * any member of it after that call!!*/ mbox->refresh(true); - if (v) { + if (v) + { v->setSelected(box,true); } @@ -726,5 +803,6 @@ void MHfolderItem::createFolder() void MHfolderItem::contextMenuSelected(int which) { - switch(which) { + switch(which) + { case 0: deleteAllMail(mbox->getWrapper(),folder); @@ -796,6 +874,8 @@ void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) QObject::tr("No",contextName),QString::null,1,1); qDebug("Auswahl: %i",yesno); - if (yesno == 0) { - if (wrapper->deleteAllMail(folder)) { + if (yesno == 0) + { + if (wrapper->deleteAllMail(folder)) + { AccountView * view = (AccountView*)listView(); if (view) view->refreshCurrent(); @@ -807,5 +887,6 @@ void AccountViewItem::removeChilds() { QListViewItem *child = firstChild(); - while ( child ) { + while ( child ) + { QListViewItem *tmp = child; child = child->nextSibling(); @@ -826,11 +907,15 @@ AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem* if (!start) pitem = (AccountViewItem*)firstChild(); else pitem = (AccountViewItem*)start->firstChild(); - while (pitem) { - if (pitem->matchName(path)) { + while (pitem) + { + if (pitem->matchName(path)) + { break; } - if (pitem->childCount()>0) { + if (pitem->childCount()>0) + { sitem = findSubItem(path,pitem); - if (sitem) { + if (sitem) + { pitem = sitem; break; |