summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-14 01:54:32 (UTC)
committer alwin <alwin>2003-12-14 01:54:32 (UTC)
commit154e03927d2b97f3f76f807fe104ac9d74035215 (patch) (unidiff)
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
@@ -49,91 +49,93 @@ IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent )
49} 49}
50 50
51IMAPviewItem::~IMAPviewItem() 51IMAPviewItem::~IMAPviewItem()
52{ 52{
53 delete wrapper; 53 delete wrapper;
54} 54}
55 55
56AbstractMail *IMAPviewItem::getWrapper() 56AbstractMail *IMAPviewItem::getWrapper()
57{ 57{
58 return wrapper; 58 return wrapper;
59} 59}
60 60
61void IMAPviewItem::refresh(QList<RecMail>&) 61void IMAPviewItem::refresh(QList<RecMail>&)
62{ 62{
63 QList<Folder> *folders = wrapper->listFolders(); 63 QList<Folder> *folders = wrapper->listFolders();
64 64
65 QListViewItem *child = firstChild(); 65 QListViewItem *child = firstChild();
66 while ( child ) { 66 while ( child ) {
67 QListViewItem *tmp = child; 67 QListViewItem *tmp = child;
68 child = child->nextSibling(); 68 child = child->nextSibling();
69 delete tmp; 69 delete tmp;
70 } 70 }
71 71
72 Folder *it; 72 Folder *it;
73 QListViewItem*item = 0;
73 for ( it = folders->first(); it; it = folders->next() ) { 74 for ( it = folders->first(); it; it = folders->next() ) {
74 (void) new IMAPfolderItem( it, this ); 75 item = new IMAPfolderItem( it, this , item );
75 } 76 }
76} 77}
77 78
78RecBody IMAPviewItem::fetchBody(const RecMail&) 79RecBody IMAPviewItem::fetchBody(const RecMail&)
79{ 80{
80 return RecBody(); 81 return RecBody();
81} 82}
82 83
83IMAPfolderItem::~IMAPfolderItem() 84IMAPfolderItem::~IMAPfolderItem()
84{ 85{
85 delete folder; 86 delete folder;
86} 87}
87 88
88IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent ) 89IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
89 : AccountViewItem( parent ) 90 : AccountViewItem( parent,after )
90{ 91{
91 folder = folderInit; 92 folder = folderInit;
92 imap = parent; 93 imap = parent;
93 setPixmap( 0, PIXMAP_IMAPFOLDER ); 94 setPixmap( 0, PIXMAP_IMAPFOLDER );
94 setText( 0, folder->getDisplayName() ); 95 setText( 0, folder->getDisplayName() );
95} 96}
96 97
97void IMAPfolderItem::refresh(QList<RecMail>&target) 98void IMAPfolderItem::refresh(QList<RecMail>&target)
98{ 99{
99 imap->getWrapper()->listMessages( folder->getName(),target ); 100 imap->getWrapper()->listMessages( folder->getName(),target );
100} 101}
101 102
102RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) 103RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
103{ 104{
104 return imap->getWrapper()->fetchBody(aMail); 105 return imap->getWrapper()->fetchBody(aMail);
105} 106}
106 107
107/** 108/**
108 * Generic stuff 109 * Generic stuff
109 */ 110 */
110 111
111AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 112AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
112 : QListView( parent, name, flags ) 113 : QListView( parent, name, flags )
113{ 114{
114 connect( this, SIGNAL( clicked( QListViewItem * ) ), 115 connect( this, SIGNAL( clicked( QListViewItem * ) ),
115 SLOT( refresh( QListViewItem * ) ) ); 116 SLOT( refresh( QListViewItem * ) ) );
117 setSorting(-1);
116} 118}
117 119
118void AccountView::populate( QList<Account> list ) 120void AccountView::populate( QList<Account> list )
119{ 121{
120 clear(); 122 clear();
121 123
122 Account *it; 124 Account *it;
123 for ( it = list.first(); it; it = list.next() ) { 125 for ( it = list.first(); it; it = list.next() ) {
124 if ( it->getType().compare( "IMAP" ) == 0 ) { 126 if ( it->getType().compare( "IMAP" ) == 0 ) {
125 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 127 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
126 qDebug( "added IMAP " + imap->getAccountName() ); 128 qDebug( "added IMAP " + imap->getAccountName() );
127 (void) new IMAPviewItem( imap, this ); 129 (void) new IMAPviewItem( imap, this );
128 } else if ( it->getType().compare( "POP3" ) == 0 ) { 130 } else if ( it->getType().compare( "POP3" ) == 0 ) {
129 POP3account *pop3 = static_cast<POP3account *>(it); 131 POP3account *pop3 = static_cast<POP3account *>(it);
130 qDebug( "added POP3 " + pop3->getAccountName() ); 132 qDebug( "added POP3 " + pop3->getAccountName() );
131 (void) new POP3viewItem( pop3, this ); 133 (void) new POP3viewItem( pop3, this );
132 } 134 }
133 } 135 }
134} 136}
135 137
136void AccountView::refresh(QListViewItem *item) { 138void AccountView::refresh(QListViewItem *item) {
137 139
138 qDebug("AccountView refresh..."); 140 qDebug("AccountView refresh...");
139 if ( item ) { 141 if ( item ) {
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,82 +1,83 @@
1#ifndef ACCOUNTVIEW_H 1#ifndef ACCOUNTVIEW_H
2#define ACCOUNTVIEW_H 2#define ACCOUNTVIEW_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7#include "settings.h" 7#include "settings.h"
8#include "mailwrapper.h" 8#include "mailwrapper.h"
9#include "abstractmail.h" 9#include "abstractmail.h"
10 10
11class POP3wrapper; 11class POP3wrapper;
12class RecMail; 12class RecMail;
13class RecBody; 13class RecBody;
14 14
15class AccountViewItem : public QListViewItem 15class AccountViewItem : public QListViewItem
16{ 16{
17 17
18public: 18public:
19 AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} 19 AccountViewItem( QListView *parent ) : QListViewItem( parent ) {}
20 AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {} 20 AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {}
21 AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {}
21 virtual void refresh(QList<RecMail>&)=0; 22 virtual void refresh(QList<RecMail>&)=0;
22 virtual RecBody fetchBody(const RecMail&)=0; 23 virtual RecBody fetchBody(const RecMail&)=0;
23}; 24};
24 25
25class POP3viewItem : public AccountViewItem 26class POP3viewItem : public AccountViewItem
26{ 27{
27 28
28public: 29public:
29 POP3viewItem( POP3account *a, QListView *parent ); 30 POP3viewItem( POP3account *a, QListView *parent );
30 ~POP3viewItem(); 31 ~POP3viewItem();
31 virtual void refresh( QList<RecMail> &target ); 32 virtual void refresh( QList<RecMail> &target );
32 virtual RecBody fetchBody( const RecMail &mail ); 33 virtual RecBody fetchBody( const RecMail &mail );
33 34
34private: 35private:
35 POP3account *account; 36 POP3account *account;
36 AbstractMail *wrapper; 37 AbstractMail *wrapper;
37 38
38}; 39};
39 40
40class IMAPviewItem : public AccountViewItem 41class IMAPviewItem : public AccountViewItem
41{ 42{
42 43
43public: 44public:
44 IMAPviewItem( IMAPaccount *a, QListView *parent ); 45 IMAPviewItem( IMAPaccount *a, QListView *parent );
45 ~IMAPviewItem(); 46 ~IMAPviewItem();
46 virtual void refresh(QList<RecMail>&); 47 virtual void refresh(QList<RecMail>&);
47 virtual RecBody fetchBody(const RecMail&); 48 virtual RecBody fetchBody(const RecMail&);
48 AbstractMail *getWrapper(); 49 AbstractMail *getWrapper();
49private: 50private:
50 IMAPaccount *account; 51 IMAPaccount *account;
51 AbstractMail *wrapper; 52 AbstractMail *wrapper;
52}; 53};
53 54
54class IMAPfolderItem : public AccountViewItem 55class IMAPfolderItem : public AccountViewItem
55{ 56{
56 57
57public: 58public:
58 IMAPfolderItem( Folder *folder, IMAPviewItem *parent ); 59 IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
59 ~IMAPfolderItem(); 60 ~IMAPfolderItem();
60 virtual void refresh(QList<RecMail>&); 61 virtual void refresh(QList<RecMail>&);
61 virtual RecBody fetchBody(const RecMail&); 62 virtual RecBody fetchBody(const RecMail&);
62private: 63private:
63 Folder *folder; 64 Folder *folder;
64 IMAPviewItem *imap; 65 IMAPviewItem *imap;
65 66
66}; 67};
67 68
68class AccountView : public QListView 69class AccountView : public QListView
69{ 70{
70 Q_OBJECT 71 Q_OBJECT
71 72
72public: 73public:
73 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 74 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
74 void populate( QList<Account> list ); 75 void populate( QList<Account> list );
75 RecBody fetchBody(const RecMail&aMail); 76 RecBody fetchBody(const RecMail&aMail);
76 77
77public slots: 78public slots:
78 void refreshAll(); 79 void refreshAll();
79 void refresh(QListViewItem *item); 80 void refresh(QListViewItem *item);
80 void refreshCurrent(); 81 void refreshCurrent();
81 82
82signals: 83signals: