author | alwin <alwin> | 2003-12-14 01:54:32 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-14 01:54:32 (UTC) |
commit | 154e03927d2b97f3f76f807fe104ac9d74035215 (patch) (unidiff) | |
tree | 11ab26b6e072f79dc9ebcb78e887b7e269f908f5 | |
parent | 898d1d9abda9889c3bb3adc44dd253e0a4ede746 (diff) | |
download | opie-154e03927d2b97f3f76f807fe104ac9d74035215.zip opie-154e03927d2b97f3f76f807fe104ac9d74035215.tar.gz opie-154e03927d2b97f3f76f807fe104ac9d74035215.tar.bz2 |
order of imapfolders will be displayed as the server lists
-rw-r--r-- | noncore/net/mail/accountview.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 5 |
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 | ||
51 | IMAPviewItem::~IMAPviewItem() | 51 | IMAPviewItem::~IMAPviewItem() |
52 | { | 52 | { |
53 | delete wrapper; | 53 | delete wrapper; |
54 | } | 54 | } |
55 | 55 | ||
56 | AbstractMail *IMAPviewItem::getWrapper() | 56 | AbstractMail *IMAPviewItem::getWrapper() |
57 | { | 57 | { |
58 | return wrapper; | 58 | return wrapper; |
59 | } | 59 | } |
60 | 60 | ||
61 | void IMAPviewItem::refresh(QList<RecMail>&) | 61 | void 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 | ||
78 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 79 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
79 | { | 80 | { |
80 | return RecBody(); | 81 | return RecBody(); |
81 | } | 82 | } |
82 | 83 | ||
83 | IMAPfolderItem::~IMAPfolderItem() | 84 | IMAPfolderItem::~IMAPfolderItem() |
84 | { | 85 | { |
85 | delete folder; | 86 | delete folder; |
86 | } | 87 | } |
87 | 88 | ||
88 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent ) | 89 | IMAPfolderItem::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 | ||
97 | void IMAPfolderItem::refresh(QList<RecMail>&target) | 98 | void 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 | ||
102 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | 103 | RecBody 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 | ||
111 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 112 | AccountView::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 | ||
118 | void AccountView::populate( QList<Account> list ) | 120 | void 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 | ||
136 | void AccountView::refresh(QListViewItem *item) { | 138 | void 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 | ||
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class RecMail; | 12 | class RecMail; |
13 | class RecBody; | 13 | class RecBody; |
14 | 14 | ||
15 | class AccountViewItem : public QListViewItem | 15 | class AccountViewItem : public QListViewItem |
16 | { | 16 | { |
17 | 17 | ||
18 | public: | 18 | public: |
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 | ||
25 | class POP3viewItem : public AccountViewItem | 26 | class POP3viewItem : public AccountViewItem |
26 | { | 27 | { |
27 | 28 | ||
28 | public: | 29 | public: |
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 | ||
34 | private: | 35 | private: |
35 | POP3account *account; | 36 | POP3account *account; |
36 | AbstractMail *wrapper; | 37 | AbstractMail *wrapper; |
37 | 38 | ||
38 | }; | 39 | }; |
39 | 40 | ||
40 | class IMAPviewItem : public AccountViewItem | 41 | class IMAPviewItem : public AccountViewItem |
41 | { | 42 | { |
42 | 43 | ||
43 | public: | 44 | public: |
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(); |
49 | private: | 50 | private: |
50 | IMAPaccount *account; | 51 | IMAPaccount *account; |
51 | AbstractMail *wrapper; | 52 | AbstractMail *wrapper; |
52 | }; | 53 | }; |
53 | 54 | ||
54 | class IMAPfolderItem : public AccountViewItem | 55 | class IMAPfolderItem : public AccountViewItem |
55 | { | 56 | { |
56 | 57 | ||
57 | public: | 58 | public: |
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&); |
62 | private: | 63 | private: |
63 | Folder *folder; | 64 | Folder *folder; |
64 | IMAPviewItem *imap; | 65 | IMAPviewItem *imap; |
65 | 66 | ||
66 | }; | 67 | }; |
67 | 68 | ||
68 | class AccountView : public QListView | 69 | class AccountView : public QListView |
69 | { | 70 | { |
70 | Q_OBJECT | 71 | Q_OBJECT |
71 | 72 | ||
72 | public: | 73 | public: |
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 | ||
77 | public slots: | 78 | public 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 | ||
82 | signals: | 83 | signals: |