Diffstat (limited to 'noncore/net/mail/accountview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/accountview.cpp | 40 |
1 files changed, 26 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) | |||
84 | 84 | ||
85 | /** | 85 | /** |
86 | * IMAP Account stuff | 86 | * IMAP Account stuff |
87 | */ | 87 | */ |
88 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 88 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) |
89 | : AccountViewItem( parent ) | 89 | : AccountViewItem( parent ) |
90 | { | 90 | { |
91 | account = a; | 91 | account = a; |
92 | wrapper = AbstractMail::getWrapper( account ); | 92 | wrapper = AbstractMail::getWrapper( account ); |
93 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 93 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
94 | setText( 0, account->getAccountName() ); | 94 | setText( 0, account->getAccountName() ); |
95 | setOpen( true ); | 95 | setOpen( true ); |
96 | } | 96 | } |
97 | 97 | ||
98 | IMAPviewItem::~IMAPviewItem() | 98 | IMAPviewItem::~IMAPviewItem() |
99 | { | 99 | { |
100 | delete wrapper; | 100 | delete wrapper; |
101 | } | 101 | } |
102 | 102 | ||
103 | AbstractMail *IMAPviewItem::getWrapper() | 103 | AbstractMail *IMAPviewItem::getWrapper() |
104 | { | 104 | { |
105 | return wrapper; | 105 | return wrapper; |
106 | } | 106 | } |
107 | 107 | ||
108 | IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) | ||
109 | { | ||
110 | IMAPfolderItem*pitem,*sitem; | ||
111 | if (!start) pitem = (IMAPfolderItem*)firstChild(); | ||
112 | else pitem = (IMAPfolderItem*)start->firstChild(); | ||
113 | while (pitem) { | ||
114 | if (pitem->matchName(path)) { | ||
115 | break; | ||
116 | } | ||
117 | if (pitem->childCount()>0) { | ||
118 | sitem = findSubItem(path,pitem); | ||
119 | if (sitem) { | ||
120 | pitem = sitem; | ||
121 | break; | ||
122 | } | ||
123 | } | ||
124 | pitem=(IMAPfolderItem*)pitem->nextSibling(); | ||
125 | } | ||
126 | return pitem; | ||
127 | } | ||
128 | |||
108 | void IMAPviewItem::refresh(QList<RecMail>&) | 129 | void IMAPviewItem::refresh(QList<RecMail>&) |
109 | { | 130 | { |
110 | if (childCount()>0) return; | 131 | if (childCount()>0) return; |
111 | QList<Folder> *folders = wrapper->listFolders(); | 132 | QList<Folder> *folders = wrapper->listFolders(); |
112 | 133 | ||
113 | QListViewItem *child = firstChild(); | 134 | QListViewItem *child = firstChild(); |
114 | while ( child ) { | 135 | while ( child ) { |
115 | QListViewItem *tmp = child; | 136 | QListViewItem *tmp = child; |
116 | child = child->nextSibling(); | 137 | child = child->nextSibling(); |
117 | delete tmp; | 138 | delete tmp; |
118 | } | 139 | } |
119 | 140 | ||
120 | Folder *it; | 141 | Folder *it; |
121 | QListViewItem*item = 0; | 142 | QListViewItem*item = 0; |
122 | QListViewItem*titem = 0; | 143 | QListViewItem*titem = 0; |
123 | QListViewItem*inboxitem = 0; | ||
124 | QString fname,del,search; | 144 | QString fname,del,search; |
125 | int pos; | 145 | int pos; |
126 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 146 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
127 | folders->setAutoDelete(false); | 147 | folders->setAutoDelete(false); |
128 | 148 | ||
129 | for ( it = folders->first(); it; it = folders->next() ) { | 149 | for ( it = folders->first(); it; it = folders->next() ) { |
130 | if (it->getDisplayName().lower()=="inbox") { | 150 | if (it->getDisplayName().lower()=="inbox") { |
131 | inboxitem = new IMAPfolderItem( it, this , item ); | 151 | item = new IMAPfolderItem( it, this , item ); |
132 | folders->remove(it); | 152 | folders->remove(it); |
133 | qDebug("inbox found"); | 153 | qDebug("inbox found"); |
134 | break; | 154 | break; |
135 | } | 155 | } |
136 | } | 156 | } |
137 | |||
138 | for ( it = folders->first(); it; it = folders->next() ) { | 157 | for ( it = folders->first(); it; it = folders->next() ) { |
139 | fname = it->getDisplayName(); | 158 | fname = it->getDisplayName(); |
140 | pos = fname.findRev(it->Separator()); | 159 | pos = fname.findRev(it->Separator()); |
141 | if (pos != -1) { | 160 | if (pos != -1) { |
142 | fname = fname.left(pos); | 161 | fname = fname.left(pos); |
143 | qDebug(fname); | ||
144 | } | ||
145 | IMAPfolderItem*pitem = (IMAPfolderItem*)firstChild(); | ||
146 | while (pitem) { | ||
147 | if (pitem->matchName(fname)) { | ||
148 | break; | ||
149 | } | ||
150 | pitem=(IMAPfolderItem*)pitem->nextSibling(); | ||
151 | } | 162 | } |
163 | IMAPfolderItem*pitem = findSubItem(fname); | ||
152 | if (pitem) { | 164 | if (pitem) { |
153 | titem = item; | 165 | titem = item; |
154 | item = new IMAPfolderItem(it,pitem,item,this); | 166 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); |
155 | item->setSelectable(it->may_select()); | 167 | item->setSelectable(it->may_select()); |
156 | /* setup the short name */ | 168 | /* setup the short name */ |
157 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); | 169 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); |
158 | item = titem; | 170 | item = titem; |
159 | } else { | 171 | } else { |
160 | item = new IMAPfolderItem( it, this , (inboxitem?inboxitem:item) ); | 172 | item = new IMAPfolderItem( it, this , item ); |
161 | item->setSelectable(it->may_select()); | 173 | item->setSelectable(it->may_select()); |
162 | } | 174 | } |
163 | } | 175 | } |
164 | delete folders; | 176 | delete folders; |
165 | } | 177 | } |
166 | 178 | ||
167 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 179 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
168 | { | 180 | { |
169 | return RecBody(); | 181 | return RecBody(); |
170 | } | 182 | } |
171 | 183 | ||
172 | IMAPfolderItem::~IMAPfolderItem() | 184 | IMAPfolderItem::~IMAPfolderItem() |
173 | { | 185 | { |
174 | delete folder; | 186 | delete folder; |
175 | } | 187 | } |
176 | 188 | ||
177 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | 189 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) |
178 | : AccountViewItem( parent ) | 190 | : AccountViewItem( parent , after ) |
179 | { | 191 | { |
180 | folder = folderInit; | 192 | folder = folderInit; |
181 | imap = parent; | 193 | imap = parent; |
182 | if (folder->getDisplayName().lower()!="inbox") { | 194 | if (folder->getDisplayName().lower()!="inbox") { |
183 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 195 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
184 | } else { | 196 | } else { |
185 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 197 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
186 | } | 198 | } |
187 | setText( 0, folder->getDisplayName() ); | 199 | setText( 0, folder->getDisplayName() ); |
188 | } | 200 | } |
189 | 201 | ||
190 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 202 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
191 | : AccountViewItem( parent,after ) | 203 | : AccountViewItem( parent,after ) |
192 | { | 204 | { |
193 | folder = folderInit; | 205 | folder = folderInit; |
194 | imap = master; | 206 | imap = master; |
195 | if (folder->getDisplayName().lower()!="inbox") { | 207 | if (folder->getDisplayName().lower()!="inbox") { |
196 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 208 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
197 | } else { | 209 | } else { |
198 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 210 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
199 | } | 211 | } |
200 | setText( 0, folder->getDisplayName() ); | 212 | setText( 0, folder->getDisplayName() ); |
201 | } | 213 | } |
202 | 214 | ||