summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-14 01:54:32 (UTC)
committer alwin <alwin>2003-12-14 01:54:32 (UTC)
commit154e03927d2b97f3f76f807fe104ac9d74035215 (patch) (side-by-side diff)
tree11ab26b6e072f79dc9ebcb78e887b7e269f908f5
parent898d1d9abda9889c3bb3adc44dd253e0a4ede746 (diff)
downloadopie-154e03927d2b97f3f76f807fe104ac9d74035215.zip
opie-154e03927d2b97f3f76f807fe104ac9d74035215.tar.gz
opie-154e03927d2b97f3f76f807fe104ac9d74035215.tar.bz2
order of imapfolders will be displayed as the server lists
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp8
-rw-r--r--noncore/net/mail/accountview.h5
2 files changed, 8 insertions, 5 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index ac4f0e0..847b099 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,170 +1,172 @@
#include "accountview.h"
#include "mailtypes.h"
#include "defines.h"
/**
* POP3 Account stuff
*/
POP3viewItem::POP3viewItem( POP3account *a, QListView *parent )
: AccountViewItem( parent )
{
account = a;
wrapper = AbstractMail::getWrapper( account );
setPixmap( 0, PIXMAP_POP3FOLDER );
setText( 0, account->getAccountName() );
}
POP3viewItem::~POP3viewItem()
{
delete wrapper;
}
void POP3viewItem::refresh( QList<RecMail> &target )
{
qDebug( "POP3: refresh" );
wrapper->listMessages("INBOX", target );
}
RecBody POP3viewItem::fetchBody( const RecMail &mail )
{
qDebug( "POP3 fetchBody" );
return wrapper->fetchBody( mail );
}
/**
* IMAP Account stuff
*/
IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent )
: AccountViewItem( parent )
{
account = a;
wrapper = AbstractMail::getWrapper( account );
setPixmap( 0, PIXMAP_IMAPFOLDER );
setText( 0, account->getAccountName() );
setOpen( true );
}
IMAPviewItem::~IMAPviewItem()
{
delete wrapper;
}
AbstractMail *IMAPviewItem::getWrapper()
{
return wrapper;
}
void IMAPviewItem::refresh(QList<RecMail>&)
{
QList<Folder> *folders = wrapper->listFolders();
QListViewItem *child = firstChild();
while ( child ) {
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
Folder *it;
+ QListViewItem*item = 0;
for ( it = folders->first(); it; it = folders->next() ) {
- (void) new IMAPfolderItem( it, this );
+ item = new IMAPfolderItem( it, this , item );
}
}
RecBody IMAPviewItem::fetchBody(const RecMail&)
{
return RecBody();
}
IMAPfolderItem::~IMAPfolderItem()
{
delete folder;
}
-IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent )
- : AccountViewItem( parent )
+IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
+ : AccountViewItem( parent,after )
{
folder = folderInit;
imap = parent;
setPixmap( 0, PIXMAP_IMAPFOLDER );
setText( 0, folder->getDisplayName() );
}
void IMAPfolderItem::refresh(QList<RecMail>&target)
{
imap->getWrapper()->listMessages( folder->getName(),target );
}
RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
{
return imap->getWrapper()->fetchBody(aMail);
}
/**
* Generic stuff
*/
AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
: QListView( parent, name, flags )
{
connect( this, SIGNAL( clicked( QListViewItem * ) ),
SLOT( refresh( QListViewItem * ) ) );
+ setSorting(-1);
}
void AccountView::populate( QList<Account> list )
{
clear();
Account *it;
for ( it = list.first(); it; it = list.next() ) {
if ( it->getType().compare( "IMAP" ) == 0 ) {
IMAPaccount *imap = static_cast<IMAPaccount *>(it);
qDebug( "added IMAP " + imap->getAccountName() );
(void) new IMAPviewItem( imap, this );
} else if ( it->getType().compare( "POP3" ) == 0 ) {
POP3account *pop3 = static_cast<POP3account *>(it);
qDebug( "added POP3 " + pop3->getAccountName() );
(void) new POP3viewItem( pop3, this );
}
}
}
void AccountView::refresh(QListViewItem *item) {
qDebug("AccountView refresh...");
if ( item ) {
m_currentItem = item;
QList<RecMail> headerlist;
headerlist.setAutoDelete(true);
AccountViewItem *view = static_cast<AccountViewItem *>(item);
view->refresh(headerlist);
emit refreshMailview(&headerlist);
}
}
void AccountView::refreshCurrent()
{
if ( !m_currentItem ) return;
QList<RecMail> headerlist;
headerlist.setAutoDelete(true);
AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
view->refresh(headerlist);
emit refreshMailview(&headerlist);
}
void AccountView::refreshAll()
{
}
RecBody AccountView::fetchBody(const RecMail&aMail)
{
QListViewItem*item = selectedItem ();
if (!item) return RecBody();
AccountViewItem *view = static_cast<AccountViewItem *>(item);
return view->fetchBody(aMail);
}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index cdc87ce..04f9b7a 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -1,89 +1,90 @@
#ifndef ACCOUNTVIEW_H
#define ACCOUNTVIEW_H
#include <qlistview.h>
#include <qlist.h>
#include "settings.h"
#include "mailwrapper.h"
#include "abstractmail.h"
class POP3wrapper;
class RecMail;
class RecBody;
class AccountViewItem : public QListViewItem
{
public:
AccountViewItem( QListView *parent ) : QListViewItem( parent ) {}
- AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {}
+ AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {}
+ AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {}
virtual void refresh(QList<RecMail>&)=0;
virtual RecBody fetchBody(const RecMail&)=0;
};
class POP3viewItem : public AccountViewItem
{
public:
POP3viewItem( POP3account *a, QListView *parent );
~POP3viewItem();
virtual void refresh( QList<RecMail> &target );
virtual RecBody fetchBody( const RecMail &mail );
private:
POP3account *account;
AbstractMail *wrapper;
};
class IMAPviewItem : public AccountViewItem
{
public:
IMAPviewItem( IMAPaccount *a, QListView *parent );
~IMAPviewItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
AbstractMail *getWrapper();
private:
IMAPaccount *account;
AbstractMail *wrapper;
};
class IMAPfolderItem : public AccountViewItem
{
public:
- IMAPfolderItem( Folder *folder, IMAPviewItem *parent );
+ IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
~IMAPfolderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
private:
Folder *folder;
IMAPviewItem *imap;
};
class AccountView : public QListView
{
Q_OBJECT
public:
AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
void populate( QList<Account> list );
RecBody fetchBody(const RecMail&aMail);
public slots:
void refreshAll();
void refresh(QListViewItem *item);
void refreshCurrent();
signals:
void refreshMailview(QList<RecMail>*);
private:
QListViewItem* m_currentItem;
};
#endif