summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-17 22:14:05 (UTC)
committer alwin <alwin>2003-12-17 22:14:05 (UTC)
commiteccc6a6362ab655b14c91a65a1cd4c89f39bd1e6 (patch) (side-by-side diff)
tree30bef45970fea14e13d46a7fd026ef80c4a9b7d0
parent0b9db8cd39412de3bdc26e8f451b0475a149c903 (diff)
downloadopie-eccc6a6362ab655b14c91a65a1cd4c89f39bd1e6.zip
opie-eccc6a6362ab655b14c91a65a1cd4c89f39bd1e6.tar.gz
opie-eccc6a6362ab655b14c91a65a1cd4c89f39bd1e6.tar.bz2
folder tree will generate better and real.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp40
-rw-r--r--noncore/net/mail/accountview.h6
2 files changed, 32 insertions, 14 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index bc13336..71a0d74 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -84,119 +84,131 @@ RecBody POP3folderItem::fetchBody(const RecMail&aMail)
/**
* 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;
}
+IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start)
+{
+ IMAPfolderItem*pitem,*sitem;
+ if (!start) pitem = (IMAPfolderItem*)firstChild();
+ else pitem = (IMAPfolderItem*)start->firstChild();
+ while (pitem) {
+ if (pitem->matchName(path)) {
+ break;
+ }
+ if (pitem->childCount()>0) {
+ sitem = findSubItem(path,pitem);
+ if (sitem) {
+ pitem = sitem;
+ break;
+ }
+ }
+ pitem=(IMAPfolderItem*)pitem->nextSibling();
+ }
+ return pitem;
+}
+
void IMAPviewItem::refresh(QList<RecMail>&)
{
if (childCount()>0) return;
QList<Folder> *folders = wrapper->listFolders();
QListViewItem *child = firstChild();
while ( child ) {
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
Folder *it;
QListViewItem*item = 0;
QListViewItem*titem = 0;
- QListViewItem*inboxitem = 0;
QString fname,del,search;
int pos;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
folders->setAutoDelete(false);
for ( it = folders->first(); it; it = folders->next() ) {
if (it->getDisplayName().lower()=="inbox") {
- inboxitem = new IMAPfolderItem( it, this , item );
+ item = new IMAPfolderItem( it, this , item );
folders->remove(it);
qDebug("inbox found");
break;
}
}
-
for ( it = folders->first(); it; it = folders->next() ) {
fname = it->getDisplayName();
pos = fname.findRev(it->Separator());
if (pos != -1) {
fname = fname.left(pos);
- qDebug(fname);
- }
- IMAPfolderItem*pitem = (IMAPfolderItem*)firstChild();
- while (pitem) {
- if (pitem->matchName(fname)) {
- break;
- }
- pitem=(IMAPfolderItem*)pitem->nextSibling();
}
+ IMAPfolderItem*pitem = findSubItem(fname);
if (pitem) {
titem = item;
- item = new IMAPfolderItem(it,pitem,item,this);
+ item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this);
item->setSelectable(it->may_select());
/* setup the short name */
item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1));
item = titem;
} else {
- item = new IMAPfolderItem( it, this , (inboxitem?inboxitem:item) );
+ item = new IMAPfolderItem( it, this , item );
item->setSelectable(it->may_select());
}
}
delete folders;
}
RecBody IMAPviewItem::fetchBody(const RecMail&)
{
return RecBody();
}
IMAPfolderItem::~IMAPfolderItem()
{
delete folder;
}
IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
- : AccountViewItem( parent )
+ : AccountViewItem( parent , after )
{
folder = folderInit;
imap = parent;
if (folder->getDisplayName().lower()!="inbox") {
setPixmap( 0, PIXMAP_IMAPFOLDER );
} else {
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
: AccountViewItem( parent,after )
{
folder = folderInit;
imap = master;
if (folder->getDisplayName().lower()!="inbox") {
setPixmap( 0, PIXMAP_IMAPFOLDER );
} else {
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index a57935f..64abed9 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -30,57 +30,63 @@ public:
POP3viewItem( POP3account *a, QListView *parent );
~POP3viewItem();
virtual void refresh( QList<RecMail> &target );
virtual RecBody fetchBody( const RecMail &mail );
AbstractMail *getWrapper();
private:
POP3account *account;
AbstractMail *wrapper;
};
class POP3folderItem : public AccountViewItem
{
public:
POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
~POP3folderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
private:
Folder *folder;
POP3viewItem *pop3;
};
+class IMAPfolderItem;
+
class IMAPviewItem : public AccountViewItem
{
public:
IMAPviewItem( IMAPaccount *a, QListView *parent );
~IMAPviewItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
AbstractMail *getWrapper();
+
+protected:
+ IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0);
+
private:
IMAPaccount *account;
AbstractMail *wrapper;
};
class IMAPfolderItem : public AccountViewItem
{
public:
IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
~IMAPfolderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
bool matchName(const QString&name)const;
private:
Folder *folder;
IMAPviewItem *imap;
};
class AccountView : public QListView
{
Q_OBJECT