-rw-r--r-- | kmicromail/accountitem.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/kmicromail/accountitem.cpp b/kmicromail/accountitem.cpp index d0321ef..1698b40 100644 --- a/kmicromail/accountitem.cpp +++ b/kmicromail/accountitem.cpp | |||
@@ -1,1140 +1,1150 @@ | |||
1 | 1 | ||
2 | #include "accountitem.h" | 2 | #include "accountitem.h" |
3 | #include "accountview.h" | 3 | #include "accountview.h" |
4 | #include "newmaildir.h" | 4 | #include "newmaildir.h" |
5 | #include "nntpgroupsdlg.h" | 5 | #include "nntpgroupsdlg.h" |
6 | #include "defines.h" | 6 | #include "defines.h" |
7 | 7 | ||
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
10 | #include <libmailwrapper/mailwrapper.h> | 10 | #include <libmailwrapper/mailwrapper.h> |
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | //#include <qpe/qpeapplication.h> | 12 | //#include <qpe/qpeapplication.h> |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <kiconloader.h> | 17 | #include <kiconloader.h> |
18 | 18 | ||
19 | using namespace Opie::Core; | 19 | using namespace Opie::Core; |
20 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 20 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
21 | /** | 21 | /** |
22 | * POP3 Account stuff | 22 | * POP3 Account stuff |
23 | */ | 23 | */ |
24 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 24 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
25 | : AccountViewItem( parent ) | 25 | : AccountViewItem( parent ) |
26 | { | 26 | { |
27 | account = a; | 27 | account = a; |
28 | wrapper = AbstractMail::getWrapper( account ); | 28 | wrapper = AbstractMail::getWrapper( account ); |
29 | SETPIX(PIXMAP_POP3FOLDER); | 29 | SETPIX(PIXMAP_POP3FOLDER); |
30 | #if 0 | 30 | #if 0 |
31 | if (!account->getOffline()) | 31 | if (!account->getOffline()) |
32 | { | 32 | { |
33 | setPixmap( 0, ); | 33 | setPixmap( 0, ); |
34 | } | 34 | } |
35 | else | 35 | else |
36 | { | 36 | { |
37 | setPixmap( 0, PIXMAP_OFFLINE ); | 37 | setPixmap( 0, PIXMAP_OFFLINE ); |
38 | } | 38 | } |
39 | #endif | 39 | #endif |
40 | setText( 0, account->getAccountName() ); | 40 | setText( 0, account->getAccountName() ); |
41 | setOpen( true ); | 41 | setOpen( true ); |
42 | } | 42 | } |
43 | 43 | ||
44 | POP3viewItem::~POP3viewItem() | 44 | POP3viewItem::~POP3viewItem() |
45 | { | 45 | { |
46 | delete wrapper; | 46 | delete wrapper; |
47 | } | 47 | } |
48 | 48 | ||
49 | AbstractMail *POP3viewItem::getWrapper() | 49 | AbstractMail *POP3viewItem::getWrapper() |
50 | { | 50 | { |
51 | return wrapper; | 51 | return wrapper; |
52 | } | 52 | } |
53 | 53 | ||
54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) | 54 | void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & ) |
55 | { | 55 | { |
56 | refresh(); | 56 | refresh(); |
57 | } | 57 | } |
58 | 58 | ||
59 | void POP3viewItem::refresh() | 59 | void POP3viewItem::refresh() |
60 | { | 60 | { |
61 | if (account->getOffline()) return; | 61 | if (account->getOffline()) return; |
62 | QValueList<FolderP> *folders = wrapper->listFolders(); | 62 | QValueList<FolderP> *folders = wrapper->listFolders(); |
63 | QListViewItem *child = firstChild(); | 63 | QListViewItem *child = firstChild(); |
64 | while ( child ) | 64 | while ( child ) |
65 | { | 65 | { |
66 | QListViewItem *tmp = child; | 66 | QListViewItem *tmp = child; |
67 | child = child->nextSibling(); | 67 | child = child->nextSibling(); |
68 | delete tmp; | 68 | delete tmp; |
69 | } | 69 | } |
70 | QValueList<FolderP>::ConstIterator it; | 70 | QValueList<FolderP>::ConstIterator it; |
71 | QListViewItem*item = 0; | 71 | QListViewItem*item = 0; |
72 | for ( it = folders->begin(); it!=folders->end(); ++it) | 72 | for ( it = folders->begin(); it!=folders->end(); ++it) |
73 | { | 73 | { |
74 | item = new POP3folderItem( (*it), this , item ); | 74 | item = new POP3folderItem( (*it), this , item ); |
75 | item->setSelectable( (*it)->may_select()); | 75 | item->setSelectable( (*it)->may_select()); |
76 | } | 76 | } |
77 | delete folders; | 77 | delete folders; |
78 | } | 78 | } |
79 | 79 | ||
80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | 80 | RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) |
81 | { | 81 | { |
82 | 82 | ||
83 | return wrapper->fetchBody( mail ); | 83 | return wrapper->fetchBody( mail ); |
84 | } | 84 | } |
85 | 85 | ||
86 | QPopupMenu * POP3viewItem::getContextMenu() | 86 | QPopupMenu * POP3viewItem::getContextMenu() |
87 | { | 87 | { |
88 | QPopupMenu *m = new QPopupMenu(0); | 88 | QPopupMenu *m = new QPopupMenu(0); |
89 | if (m) | 89 | if (m) |
90 | { | 90 | { |
91 | if (!account->getOffline()) | 91 | if (!account->getOffline()) |
92 | { | 92 | { |
93 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 93 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
94 | m->insertItem(QObject::tr("Set offline",contextName),1); | 94 | m->insertItem(QObject::tr("Set offline",contextName),1); |
95 | m->insertItem(QObject::tr("Download messages",contextName),2); | ||
95 | } | 96 | } |
96 | else | 97 | else |
97 | { | 98 | { |
98 | m->insertItem(QObject::tr("Set online",contextName),1); | 99 | m->insertItem(QObject::tr("Set online",contextName),1); |
99 | } | 100 | } |
100 | } | 101 | } |
101 | return m; | 102 | return m; |
102 | } | 103 | } |
103 | 104 | ||
104 | void POP3viewItem::disconnect() | 105 | void POP3viewItem::disconnect() |
105 | { | 106 | { |
106 | QListViewItem *child = firstChild(); | 107 | QListViewItem *child = firstChild(); |
107 | while ( child ) | 108 | while ( child ) |
108 | { | 109 | { |
109 | QListViewItem *tmp = child; | 110 | QListViewItem *tmp = child; |
110 | child = child->nextSibling(); | 111 | child = child->nextSibling(); |
111 | delete tmp; | 112 | delete tmp; |
112 | } | 113 | } |
113 | wrapper->logout(); | 114 | wrapper->logout(); |
114 | } | 115 | } |
115 | 116 | ||
116 | void POP3viewItem::setOnOffline() | 117 | void POP3viewItem::setOnOffline() |
117 | { | 118 | { |
118 | if (!account->getOffline()) | 119 | if (!account->getOffline()) |
119 | { | 120 | { |
120 | disconnect(); | 121 | disconnect(); |
121 | } | 122 | } |
122 | account->setOffline(!account->getOffline()); | 123 | account->setOffline(!account->getOffline()); |
123 | account->save(); | 124 | account->save(); |
124 | SETPIX(PIXMAP_POP3FOLDER); | 125 | SETPIX(PIXMAP_POP3FOLDER); |
125 | refresh(); | 126 | refresh(); |
126 | } | 127 | } |
127 | 128 | ||
128 | void POP3viewItem::contextMenuSelected(int which) | 129 | void POP3viewItem::contextMenuSelected(int which) |
129 | { | 130 | { |
130 | switch (which) | 131 | switch (which) |
131 | { | 132 | { |
132 | case 0: | 133 | case 0: |
133 | disconnect(); | 134 | disconnect(); |
134 | break; | 135 | break; |
135 | case 1: | 136 | case 1: |
136 | setOnOffline(); | 137 | setOnOffline(); |
137 | break; | 138 | break; |
139 | case 2: // daunlood | ||
140 | AccountView*bl = accountView(); | ||
141 | if (!bl) return; | ||
142 | AccountViewItem* in = findSubItem( "inbox" , 0); | ||
143 | if ( ! in ) | ||
144 | return; | ||
145 | bl->downloadMailsInbox(in->getFolder() ,getWrapper()); | ||
146 | setOnOffline(); | ||
147 | break; | ||
138 | } | 148 | } |
139 | } | 149 | } |
140 | 150 | ||
141 | POP3folderItem::~POP3folderItem() | 151 | POP3folderItem::~POP3folderItem() |
142 | {} | 152 | {} |
143 | 153 | ||
144 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 154 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
145 | : AccountViewItem(folderInit,parent,after ) | 155 | : AccountViewItem(folderInit,parent,after ) |
146 | { | 156 | { |
147 | pop3 = parent; | 157 | pop3 = parent; |
148 | if (folder->getDisplayName().lower()!="inbox") | 158 | if (folder->getDisplayName().lower()!="inbox") |
149 | { | 159 | { |
150 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 160 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
151 | } | 161 | } |
152 | else | 162 | else |
153 | { | 163 | { |
154 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 164 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
155 | } | 165 | } |
156 | setText( 0, folder->getDisplayName() ); | 166 | setText( 0, folder->getDisplayName() ); |
157 | } | 167 | } |
158 | 168 | ||
159 | void POP3folderItem::refresh(QValueList<RecMailP>&target) | 169 | void POP3folderItem::refresh(QValueList<RecMailP>&target) |
160 | { | 170 | { |
161 | if (folder->may_select()) | 171 | if (folder->may_select()) |
162 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 172 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
163 | } | 173 | } |
164 | 174 | ||
165 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 175 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
166 | { | 176 | { |
167 | return pop3->getWrapper()->fetchBody(aMail); | 177 | return pop3->getWrapper()->fetchBody(aMail); |
168 | } | 178 | } |
169 | 179 | ||
170 | QPopupMenu * POP3folderItem::getContextMenu() | 180 | QPopupMenu * POP3folderItem::getContextMenu() |
171 | { | 181 | { |
172 | QPopupMenu *m = new QPopupMenu(0); | 182 | QPopupMenu *m = new QPopupMenu(0); |
173 | if (m) | 183 | if (m) |
174 | { | 184 | { |
175 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 185 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
176 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 186 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
177 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 187 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
178 | } | 188 | } |
179 | return m; | 189 | return m; |
180 | } | 190 | } |
181 | 191 | ||
182 | void POP3folderItem::downloadMails() | 192 | void POP3folderItem::downloadMails() |
183 | { | 193 | { |
184 | AccountView*bl = pop3->accountView(); | 194 | AccountView*bl = pop3->accountView(); |
185 | if (!bl) return; | 195 | if (!bl) return; |
186 | bl->downloadMails(folder,pop3->getWrapper()); | 196 | bl->downloadMails(folder,pop3->getWrapper()); |
187 | } | 197 | } |
188 | 198 | ||
189 | void POP3folderItem::contextMenuSelected(int which) | 199 | void POP3folderItem::contextMenuSelected(int which) |
190 | { | 200 | { |
191 | AccountView * view = (AccountView*)listView(); | 201 | AccountView * view = (AccountView*)listView(); |
192 | switch (which) | 202 | switch (which) |
193 | { | 203 | { |
194 | case 0: | 204 | case 0: |
195 | /* must be 'cause pop3 lists are cached */ | 205 | /* must be 'cause pop3 lists are cached */ |
196 | pop3->getWrapper()->logout(); | 206 | pop3->getWrapper()->logout(); |
197 | view->refreshCurrent(); | 207 | view->refreshCurrent(); |
198 | break; | 208 | break; |
199 | case 1: | 209 | case 1: |
200 | deleteAllMail(pop3->getWrapper(),folder); | 210 | deleteAllMail(pop3->getWrapper(),folder); |
201 | break; | 211 | break; |
202 | case 2: | 212 | case 2: |
203 | downloadMails(); | 213 | downloadMails(); |
204 | break; | 214 | break; |
205 | default: | 215 | default: |
206 | break; | 216 | break; |
207 | } | 217 | } |
208 | } | 218 | } |
209 | 219 | ||
210 | /** | 220 | /** |
211 | * NNTP Account stuff | 221 | * NNTP Account stuff |
212 | */ | 222 | */ |
213 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 223 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
214 | : AccountViewItem( parent ) | 224 | : AccountViewItem( parent ) |
215 | { | 225 | { |
216 | account = a; | 226 | account = a; |
217 | wrapper = AbstractMail::getWrapper( account ); | 227 | wrapper = AbstractMail::getWrapper( account ); |
218 | //FIXME | 228 | //FIXME |
219 | SETPIX(PIXMAP_POP3FOLDER); | 229 | SETPIX(PIXMAP_POP3FOLDER); |
220 | #if 0 | 230 | #if 0 |
221 | if (!account->getOffline()) | 231 | if (!account->getOffline()) |
222 | { | 232 | { |
223 | setPixmap( 0, ); | 233 | setPixmap( 0, ); |
224 | } | 234 | } |
225 | else | 235 | else |
226 | { | 236 | { |
227 | setPixmap( 0, PIXMAP_OFFLINE ); | 237 | setPixmap( 0, PIXMAP_OFFLINE ); |
228 | } | 238 | } |
229 | #endif | 239 | #endif |
230 | setText( 0, account->getAccountName() ); | 240 | setText( 0, account->getAccountName() ); |
231 | setOpen( true ); | 241 | setOpen( true ); |
232 | } | 242 | } |
233 | 243 | ||
234 | NNTPviewItem::~NNTPviewItem() | 244 | NNTPviewItem::~NNTPviewItem() |
235 | { | 245 | { |
236 | delete wrapper; | 246 | delete wrapper; |
237 | } | 247 | } |
238 | 248 | ||
239 | AbstractMail *NNTPviewItem::getWrapper() | 249 | AbstractMail *NNTPviewItem::getWrapper() |
240 | { | 250 | { |
241 | return wrapper; | 251 | return wrapper; |
242 | } | 252 | } |
243 | 253 | ||
244 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) | 254 | void NNTPviewItem::refresh( QValueList<RecMailP> & ) |
245 | { | 255 | { |
246 | refresh(); | 256 | refresh(); |
247 | } | 257 | } |
248 | 258 | ||
249 | void NNTPviewItem::refresh() | 259 | void NNTPviewItem::refresh() |
250 | { | 260 | { |
251 | if (account->getOffline()) return; | 261 | if (account->getOffline()) return; |
252 | QValueList<FolderP> *folders = wrapper->listFolders(); | 262 | QValueList<FolderP> *folders = wrapper->listFolders(); |
253 | 263 | ||
254 | QListViewItem *child = firstChild(); | 264 | QListViewItem *child = firstChild(); |
255 | while ( child ) | 265 | while ( child ) |
256 | { | 266 | { |
257 | QListViewItem *tmp = child; | 267 | QListViewItem *tmp = child; |
258 | child = child->nextSibling(); | 268 | child = child->nextSibling(); |
259 | delete tmp; | 269 | delete tmp; |
260 | } | 270 | } |
261 | QValueList<FolderP>::ConstIterator it; | 271 | QValueList<FolderP>::ConstIterator it; |
262 | QListViewItem*item = 0; | 272 | QListViewItem*item = 0; |
263 | for ( it = folders->begin(); it!=folders->end(); ++it) | 273 | for ( it = folders->begin(); it!=folders->end(); ++it) |
264 | { | 274 | { |
265 | item = new NNTPfolderItem( (*it), this , item ); | 275 | item = new NNTPfolderItem( (*it), this , item ); |
266 | item->setSelectable( (*it)->may_select()); | 276 | item->setSelectable( (*it)->may_select()); |
267 | } | 277 | } |
268 | delete folders; | 278 | delete folders; |
269 | } | 279 | } |
270 | 280 | ||
271 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) | 281 | RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) |
272 | { | 282 | { |
273 | 283 | ||
274 | return wrapper->fetchBody( mail ); | 284 | return wrapper->fetchBody( mail ); |
275 | } | 285 | } |
276 | 286 | ||
277 | QPopupMenu * NNTPviewItem::getContextMenu() | 287 | QPopupMenu * NNTPviewItem::getContextMenu() |
278 | { | 288 | { |
279 | QPopupMenu *m = new QPopupMenu(0); | 289 | QPopupMenu *m = new QPopupMenu(0); |
280 | if (m) | 290 | if (m) |
281 | { | 291 | { |
282 | if (!account->getOffline()) | 292 | if (!account->getOffline()) |
283 | { | 293 | { |
284 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 294 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
285 | m->insertItem(QObject::tr("Set offline",contextName),1); | 295 | m->insertItem(QObject::tr("Set offline",contextName),1); |
286 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); | 296 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); |
287 | } | 297 | } |
288 | else | 298 | else |
289 | { | 299 | { |
290 | m->insertItem(QObject::tr("Set online",contextName),1); | 300 | m->insertItem(QObject::tr("Set online",contextName),1); |
291 | } | 301 | } |
292 | } | 302 | } |
293 | return m; | 303 | return m; |
294 | } | 304 | } |
295 | 305 | ||
296 | void NNTPviewItem::subscribeGroups() | 306 | void NNTPviewItem::subscribeGroups() |
297 | { | 307 | { |
298 | NNTPGroupsDlg dlg(account); | 308 | NNTPGroupsDlg dlg(account); |
299 | dlg.showMaximized(); | 309 | dlg.showMaximized(); |
300 | if ( dlg.exec()== QDialog::Accepted ){ | 310 | if ( dlg.exec()== QDialog::Accepted ){ |
301 | refresh(); | 311 | refresh(); |
302 | } | 312 | } |
303 | } | 313 | } |
304 | 314 | ||
305 | void NNTPviewItem::disconnect() | 315 | void NNTPviewItem::disconnect() |
306 | { | 316 | { |
307 | QListViewItem *child = firstChild(); | 317 | QListViewItem *child = firstChild(); |
308 | while ( child ) | 318 | while ( child ) |
309 | { | 319 | { |
310 | QListViewItem *tmp = child; | 320 | QListViewItem *tmp = child; |
311 | child = child->nextSibling(); | 321 | child = child->nextSibling(); |
312 | delete tmp; | 322 | delete tmp; |
313 | } | 323 | } |
314 | wrapper->logout(); | 324 | wrapper->logout(); |
315 | } | 325 | } |
316 | 326 | ||
317 | void NNTPviewItem::setOnOffline() | 327 | void NNTPviewItem::setOnOffline() |
318 | { | 328 | { |
319 | if (!account->getOffline()) | 329 | if (!account->getOffline()) |
320 | { | 330 | { |
321 | disconnect(); | 331 | disconnect(); |
322 | } | 332 | } |
323 | account->setOffline(!account->getOffline()); | 333 | account->setOffline(!account->getOffline()); |
324 | account->save(); | 334 | account->save(); |
325 | //FIXME | 335 | //FIXME |
326 | SETPIX(PIXMAP_POP3FOLDER); | 336 | SETPIX(PIXMAP_POP3FOLDER); |
327 | refresh(); | 337 | refresh(); |
328 | } | 338 | } |
329 | 339 | ||
330 | void NNTPviewItem::contextMenuSelected(int which) | 340 | void NNTPviewItem::contextMenuSelected(int which) |
331 | { | 341 | { |
332 | switch (which) | 342 | switch (which) |
333 | { | 343 | { |
334 | case 0: | 344 | case 0: |
335 | disconnect(); | 345 | disconnect(); |
336 | break; | 346 | break; |
337 | case 1: | 347 | case 1: |
338 | setOnOffline(); | 348 | setOnOffline(); |
339 | break; | 349 | break; |
340 | case 2: | 350 | case 2: |
341 | subscribeGroups(); | 351 | subscribeGroups(); |
342 | break; | 352 | break; |
343 | } | 353 | } |
344 | } | 354 | } |
345 | 355 | ||
346 | NNTPfolderItem::~NNTPfolderItem() | 356 | NNTPfolderItem::~NNTPfolderItem() |
347 | {} | 357 | {} |
348 | 358 | ||
349 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) | 359 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) |
350 | : AccountViewItem( folderInit, parent,after ) | 360 | : AccountViewItem( folderInit, parent,after ) |
351 | { | 361 | { |
352 | nntp = parent; | 362 | nntp = parent; |
353 | if (folder->getDisplayName().lower()!="inbox") | 363 | if (folder->getDisplayName().lower()!="inbox") |
354 | { | 364 | { |
355 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 365 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
356 | } | 366 | } |
357 | else | 367 | else |
358 | { | 368 | { |
359 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 369 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
360 | } | 370 | } |
361 | setText( 0, folder->getDisplayName() ); | 371 | setText( 0, folder->getDisplayName() ); |
362 | } | 372 | } |
363 | 373 | ||
364 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) | 374 | void NNTPfolderItem::refresh(QValueList<RecMailP>&target) |
365 | { | 375 | { |
366 | if (folder->may_select()) | 376 | if (folder->may_select()) |
367 | nntp->getWrapper()->listMessages( folder->getName(),target ); | 377 | nntp->getWrapper()->listMessages( folder->getName(),target ); |
368 | } | 378 | } |
369 | 379 | ||
370 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) | 380 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) |
371 | { | 381 | { |
372 | return nntp->getWrapper()->fetchBody(aMail); | 382 | return nntp->getWrapper()->fetchBody(aMail); |
373 | } | 383 | } |
374 | 384 | ||
375 | QPopupMenu * NNTPfolderItem::getContextMenu() | 385 | QPopupMenu * NNTPfolderItem::getContextMenu() |
376 | { | 386 | { |
377 | QPopupMenu *m = new QPopupMenu(0); | 387 | QPopupMenu *m = new QPopupMenu(0); |
378 | if (m) | 388 | if (m) |
379 | { | 389 | { |
380 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 390 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
381 | m->insertItem(QObject::tr("Copy all postings",contextName),1); | 391 | m->insertItem(QObject::tr("Copy all postings",contextName),1); |
382 | } | 392 | } |
383 | return m; | 393 | return m; |
384 | } | 394 | } |
385 | 395 | ||
386 | void NNTPfolderItem::downloadMails() | 396 | void NNTPfolderItem::downloadMails() |
387 | { | 397 | { |
388 | AccountView*bl = nntp->accountView(); | 398 | AccountView*bl = nntp->accountView(); |
389 | if (!bl) return; | 399 | if (!bl) return; |
390 | bl->downloadMails(folder,nntp->getWrapper()); | 400 | bl->downloadMails(folder,nntp->getWrapper()); |
391 | } | 401 | } |
392 | 402 | ||
393 | void NNTPfolderItem::contextMenuSelected(int which) | 403 | void NNTPfolderItem::contextMenuSelected(int which) |
394 | { | 404 | { |
395 | AccountView * view = (AccountView*)listView(); | 405 | AccountView * view = (AccountView*)listView(); |
396 | switch (which) | 406 | switch (which) |
397 | { | 407 | { |
398 | case 0: | 408 | case 0: |
399 | /* must be 'cause pop3 lists are cached */ | 409 | /* must be 'cause pop3 lists are cached */ |
400 | nntp->getWrapper()->logout(); | 410 | nntp->getWrapper()->logout(); |
401 | view->refreshCurrent(); | 411 | view->refreshCurrent(); |
402 | break; | 412 | break; |
403 | case 1: | 413 | case 1: |
404 | downloadMails(); | 414 | downloadMails(); |
405 | break; | 415 | break; |
406 | default: | 416 | default: |
407 | break; | 417 | break; |
408 | } | 418 | } |
409 | } | 419 | } |
410 | 420 | ||
411 | /** | 421 | /** |
412 | * IMAP Account stuff | 422 | * IMAP Account stuff |
413 | */ | 423 | */ |
414 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 424 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
415 | : AccountViewItem( parent ) | 425 | : AccountViewItem( parent ) |
416 | { | 426 | { |
417 | account = a; | 427 | account = a; |
418 | wrapper = AbstractMail::getWrapper( account ); | 428 | wrapper = AbstractMail::getWrapper( account ); |
419 | SETPIX(PIXMAP_IMAPFOLDER); | 429 | SETPIX(PIXMAP_IMAPFOLDER); |
420 | setText( 0, account->getAccountName() ); | 430 | setText( 0, account->getAccountName() ); |
421 | setOpen( true ); | 431 | setOpen( true ); |
422 | } | 432 | } |
423 | 433 | ||
424 | IMAPviewItem::~IMAPviewItem() | 434 | IMAPviewItem::~IMAPviewItem() |
425 | { | 435 | { |
426 | delete wrapper; | 436 | delete wrapper; |
427 | } | 437 | } |
428 | 438 | ||
429 | AbstractMail *IMAPviewItem::getWrapper() | 439 | AbstractMail *IMAPviewItem::getWrapper() |
430 | { | 440 | { |
431 | return wrapper; | 441 | return wrapper; |
432 | } | 442 | } |
433 | 443 | ||
434 | void IMAPviewItem::refresh(QValueList<RecMailP>&) | 444 | void IMAPviewItem::refresh(QValueList<RecMailP>&) |
435 | { | 445 | { |
436 | refreshFolders(false); | 446 | refreshFolders(false); |
437 | } | 447 | } |
438 | 448 | ||
439 | const QStringList&IMAPviewItem::subFolders() | 449 | const QStringList&IMAPviewItem::subFolders() |
440 | { | 450 | { |
441 | return currentFolders; | 451 | return currentFolders; |
442 | } | 452 | } |
443 | 453 | ||
444 | void IMAPviewItem::refreshFolders(bool force) | 454 | void IMAPviewItem::refreshFolders(bool force) |
445 | { | 455 | { |
446 | if (childCount()>0 && force==false) return; | 456 | if (childCount()>0 && force==false) return; |
447 | if (account->getOffline()) return; | 457 | if (account->getOffline()) return; |
448 | 458 | ||
449 | removeChilds(); | 459 | removeChilds(); |
450 | currentFolders.clear(); | 460 | currentFolders.clear(); |
451 | QValueList<FolderP> * folders = wrapper->listFolders(); | 461 | QValueList<FolderP> * folders = wrapper->listFolders(); |
452 | 462 | ||
453 | QValueList<FolderP>::Iterator it; | 463 | QValueList<FolderP>::Iterator it; |
454 | QListViewItem*item = 0; | 464 | QListViewItem*item = 0; |
455 | QListViewItem*titem = 0; | 465 | QListViewItem*titem = 0; |
456 | QString fname,del,search; | 466 | QString fname,del,search; |
457 | int pos; | 467 | int pos; |
458 | 468 | ||
459 | for ( it = folders->begin(); it!=folders->end(); ++it) | 469 | for ( it = folders->begin(); it!=folders->end(); ++it) |
460 | { | 470 | { |
461 | if ((*it)->getDisplayName().lower()=="inbox") | 471 | if ((*it)->getDisplayName().lower()=="inbox") |
462 | { | 472 | { |
463 | item = new IMAPfolderItem( (*it), this , item ); | 473 | item = new IMAPfolderItem( (*it), this , item ); |
464 | folders->remove(it); | 474 | folders->remove(it); |
465 | break; | 475 | break; |
466 | } | 476 | } |
467 | } | 477 | } |
468 | for ( it = folders->begin(); it!=folders->end(); ++it) | 478 | for ( it = folders->begin(); it!=folders->end(); ++it) |
469 | { | 479 | { |
470 | fname = (*it)->getDisplayName(); | 480 | fname = (*it)->getDisplayName(); |
471 | currentFolders.append((*it)->getName()); | 481 | currentFolders.append((*it)->getName()); |
472 | pos = fname.findRev((*it)->Separator()); | 482 | pos = fname.findRev((*it)->Separator()); |
473 | if (pos != -1) | 483 | if (pos != -1) |
474 | { | 484 | { |
475 | fname = fname.left(pos); | 485 | fname = fname.left(pos); |
476 | } | 486 | } |
477 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 487 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
478 | if (pitem) | 488 | if (pitem) |
479 | { | 489 | { |
480 | titem = item; | 490 | titem = item; |
481 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); | 491 | item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); |
482 | /* setup the short name */ | 492 | /* setup the short name */ |
483 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); | 493 | item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); |
484 | item = titem; | 494 | item = titem; |
485 | } | 495 | } |
486 | else | 496 | else |
487 | { | 497 | { |
488 | item = new IMAPfolderItem( (*it), this , item ); | 498 | item = new IMAPfolderItem( (*it), this , item ); |
489 | } | 499 | } |
490 | } | 500 | } |
491 | delete folders; | 501 | delete folders; |
492 | } | 502 | } |
493 | 503 | ||
494 | QPopupMenu * IMAPviewItem::getContextMenu() | 504 | QPopupMenu * IMAPviewItem::getContextMenu() |
495 | { | 505 | { |
496 | QPopupMenu *m = new QPopupMenu(0); | 506 | QPopupMenu *m = new QPopupMenu(0); |
497 | if (m) | 507 | if (m) |
498 | { | 508 | { |
499 | if (!account->getOffline()) | 509 | if (!account->getOffline()) |
500 | { | 510 | { |
501 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 511 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
502 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 512 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
503 | m->insertSeparator(); | 513 | m->insertSeparator(); |
504 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 514 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
505 | m->insertItem(QObject::tr("Set offline",contextName),3); | 515 | m->insertItem(QObject::tr("Set offline",contextName),3); |
506 | } | 516 | } |
507 | else | 517 | else |
508 | { | 518 | { |
509 | m->insertItem(QObject::tr("Set online",contextName),3); | 519 | m->insertItem(QObject::tr("Set online",contextName),3); |
510 | } | 520 | } |
511 | } | 521 | } |
512 | return m; | 522 | return m; |
513 | } | 523 | } |
514 | 524 | ||
515 | void IMAPviewItem::createNewFolder() | 525 | void IMAPviewItem::createNewFolder() |
516 | { | 526 | { |
517 | Newmdirdlg ndirdlg; | 527 | Newmdirdlg ndirdlg; |
518 | 528 | ||
519 | ndirdlg.showMaximized(); | 529 | ndirdlg.showMaximized(); |
520 | if ( ndirdlg.exec() ) | 530 | if ( ndirdlg.exec() ) |
521 | { | 531 | { |
522 | QString ndir = ndirdlg.Newdir(); | 532 | QString ndir = ndirdlg.Newdir(); |
523 | bool makesubs = ndirdlg.subpossible(); | 533 | bool makesubs = ndirdlg.subpossible(); |
524 | QString delemiter = "/"; | 534 | QString delemiter = "/"; |
525 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 535 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
526 | if (item) | 536 | if (item) |
527 | { | 537 | { |
528 | delemiter = item->Delemiter(); | 538 | delemiter = item->Delemiter(); |
529 | } | 539 | } |
530 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 540 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
531 | { | 541 | { |
532 | refreshFolders(true); | 542 | refreshFolders(true); |
533 | } | 543 | } |
534 | } | 544 | } |
535 | } | 545 | } |
536 | 546 | ||
537 | void IMAPviewItem::contextMenuSelected(int id) | 547 | void IMAPviewItem::contextMenuSelected(int id) |
538 | { | 548 | { |
539 | 549 | ||
540 | switch (id) | 550 | switch (id) |
541 | { | 551 | { |
542 | case 0: | 552 | case 0: |
543 | refreshFolders(true); | 553 | refreshFolders(true); |
544 | break; | 554 | break; |
545 | case 1: | 555 | case 1: |
546 | createNewFolder(); | 556 | createNewFolder(); |
547 | break; | 557 | break; |
548 | case 2: | 558 | case 2: |
549 | removeChilds(); | 559 | removeChilds(); |
550 | wrapper->logout(); | 560 | wrapper->logout(); |
551 | break; | 561 | break; |
552 | case 3: | 562 | case 3: |
553 | if (account->getOffline()==false) | 563 | if (account->getOffline()==false) |
554 | { | 564 | { |
555 | removeChilds(); | 565 | removeChilds(); |
556 | wrapper->logout(); | 566 | wrapper->logout(); |
557 | } | 567 | } |
558 | account->setOffline(!account->getOffline()); | 568 | account->setOffline(!account->getOffline()); |
559 | account->save(); | 569 | account->save(); |
560 | SETPIX(PIXMAP_IMAPFOLDER); | 570 | SETPIX(PIXMAP_IMAPFOLDER); |
561 | refreshFolders(false); | 571 | refreshFolders(false); |
562 | break; | 572 | break; |
563 | default: | 573 | default: |
564 | break; | 574 | break; |
565 | } | 575 | } |
566 | } | 576 | } |
567 | 577 | ||
568 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) | 578 | RECBODYP IMAPviewItem::fetchBody(const RecMailP&) |
569 | { | 579 | { |
570 | return new RecBody(); | 580 | return new RecBody(); |
571 | } | 581 | } |
572 | 582 | ||
573 | bool IMAPviewItem::offline() | 583 | bool IMAPviewItem::offline() |
574 | { | 584 | { |
575 | return account->getOffline(); | 585 | return account->getOffline(); |
576 | } | 586 | } |
577 | 587 | ||
578 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) | 588 | IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) |
579 | : AccountViewItem( folderInit, parent , after ) | 589 | : AccountViewItem( folderInit, parent , after ) |
580 | { | 590 | { |
581 | imap = parent; | 591 | imap = parent; |
582 | if (folder->getDisplayName().lower()!="inbox") | 592 | if (folder->getDisplayName().lower()!="inbox") |
583 | { | 593 | { |
584 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 594 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
585 | } | 595 | } |
586 | else | 596 | else |
587 | { | 597 | { |
588 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 598 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
589 | } | 599 | } |
590 | setText( 0, folder->getDisplayName() ); | 600 | setText( 0, folder->getDisplayName() ); |
591 | } | 601 | } |
592 | 602 | ||
593 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 603 | IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
594 | : AccountViewItem(folderInit, parent,after ) | 604 | : AccountViewItem(folderInit, parent,after ) |
595 | { | 605 | { |
596 | imap = master; | 606 | imap = master; |
597 | if (folder->getDisplayName().lower()!="inbox") | 607 | if (folder->getDisplayName().lower()!="inbox") |
598 | { | 608 | { |
599 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 609 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
600 | } | 610 | } |
601 | else | 611 | else |
602 | { | 612 | { |
603 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 613 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
604 | } | 614 | } |
605 | setText( 0, folder->getDisplayName() ); | 615 | setText( 0, folder->getDisplayName() ); |
606 | } | 616 | } |
607 | 617 | ||
608 | IMAPfolderItem::~IMAPfolderItem() | 618 | IMAPfolderItem::~IMAPfolderItem() |
609 | {} | 619 | {} |
610 | 620 | ||
611 | const QString& IMAPfolderItem::Delemiter()const | 621 | const QString& IMAPfolderItem::Delemiter()const |
612 | { | 622 | { |
613 | return folder->Separator(); | 623 | return folder->Separator(); |
614 | } | 624 | } |
615 | 625 | ||
616 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | 626 | void IMAPfolderItem::refresh(QValueList<RecMailP>&target) |
617 | { | 627 | { |
618 | if (folder->may_select()) | 628 | if (folder->may_select()) |
619 | { | 629 | { |
620 | imap->getWrapper()->listMessages( folder->getName(),target ); | 630 | imap->getWrapper()->listMessages( folder->getName(),target ); |
621 | } | 631 | } |
622 | else | 632 | else |
623 | { | 633 | { |
624 | target.clear(); | 634 | target.clear(); |
625 | } | 635 | } |
626 | } | 636 | } |
627 | 637 | ||
628 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) | 638 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
629 | { | 639 | { |
630 | return imap->getWrapper()->fetchBody(aMail); | 640 | return imap->getWrapper()->fetchBody(aMail); |
631 | } | 641 | } |
632 | 642 | ||
633 | QPopupMenu * IMAPfolderItem::getContextMenu() | 643 | QPopupMenu * IMAPfolderItem::getContextMenu() |
634 | { | 644 | { |
635 | QPopupMenu *m = new QPopupMenu(0); | 645 | QPopupMenu *m = new QPopupMenu(0); |
636 | if (m) | 646 | if (m) |
637 | { | 647 | { |
638 | if (folder->may_select()) | 648 | if (folder->may_select()) |
639 | { | 649 | { |
640 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 650 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
641 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | 651 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); |
642 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 652 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
643 | } | 653 | } |
644 | if (folder->no_inferior()==false) | 654 | if (folder->no_inferior()==false) |
645 | { | 655 | { |
646 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 656 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
647 | } | 657 | } |
648 | if (folder->getDisplayName().lower()!="inbox") | 658 | if (folder->getDisplayName().lower()!="inbox") |
649 | { | 659 | { |
650 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 660 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
651 | } | 661 | } |
652 | } | 662 | } |
653 | return m; | 663 | return m; |
654 | } | 664 | } |
655 | 665 | ||
656 | void IMAPfolderItem::createNewFolder() | 666 | void IMAPfolderItem::createNewFolder() |
657 | { | 667 | { |
658 | Newmdirdlg ndirdlg; | 668 | Newmdirdlg ndirdlg; |
659 | ndirdlg.showMaximized(); | 669 | ndirdlg.showMaximized(); |
660 | if ( ndirdlg.exec() ) | 670 | if ( ndirdlg.exec() ) |
661 | { | 671 | { |
662 | QString ndir = ndirdlg.Newdir(); | 672 | QString ndir = ndirdlg.Newdir(); |
663 | bool makesubs = ndirdlg.subpossible(); | 673 | bool makesubs = ndirdlg.subpossible(); |
664 | QString delemiter = Delemiter(); | 674 | QString delemiter = Delemiter(); |
665 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 675 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
666 | { | 676 | { |
667 | imap->refreshFolders(true); | 677 | imap->refreshFolders(true); |
668 | } | 678 | } |
669 | } | 679 | } |
670 | } | 680 | } |
671 | 681 | ||
672 | void IMAPfolderItem::deleteFolder() | 682 | void IMAPfolderItem::deleteFolder() |
673 | { | 683 | { |
674 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 684 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
675 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 685 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
676 | QObject::tr("Yes",contextName), | 686 | QObject::tr("Yes",contextName), |
677 | QObject::tr("No",contextName),QString::null,1,1); | 687 | QObject::tr("No",contextName),QString::null,1,1); |
678 | 688 | ||
679 | if (yesno == 0) | 689 | if (yesno == 0) |
680 | { | 690 | { |
681 | if (imap->getWrapper()->deleteMbox(folder)) | 691 | if (imap->getWrapper()->deleteMbox(folder)) |
682 | { | 692 | { |
683 | QListView*v=listView(); | 693 | QListView*v=listView(); |
684 | IMAPviewItem * box = imap; | 694 | IMAPviewItem * box = imap; |
685 | /* be carefull - after that this object is destroyd so don't use | 695 | /* be carefull - after that this object is destroyd so don't use |
686 | * any member of it after that call!!*/ | 696 | * any member of it after that call!!*/ |
687 | imap->refreshFolders(true); | 697 | imap->refreshFolders(true); |
688 | if (v) | 698 | if (v) |
689 | { | 699 | { |
690 | v->setSelected(box,true); | 700 | v->setSelected(box,true); |
691 | } | 701 | } |
692 | } | 702 | } |
693 | } | 703 | } |
694 | } | 704 | } |
695 | 705 | ||
696 | void IMAPfolderItem::downloadMails() | 706 | void IMAPfolderItem::downloadMails() |
697 | { | 707 | { |
698 | AccountView*bl = imap->accountView(); | 708 | AccountView*bl = imap->accountView(); |
699 | if (!bl) return; | 709 | if (!bl) return; |
700 | bl->downloadMails(folder,imap->getWrapper()); | 710 | bl->downloadMails(folder,imap->getWrapper()); |
701 | } | 711 | } |
702 | 712 | ||
703 | void IMAPfolderItem::contextMenuSelected(int id) | 713 | void IMAPfolderItem::contextMenuSelected(int id) |
704 | { | 714 | { |
705 | 715 | ||
706 | AccountView * view = (AccountView*)listView(); | 716 | AccountView * view = (AccountView*)listView(); |
707 | switch(id) | 717 | switch(id) |
708 | { | 718 | { |
709 | case 0: | 719 | case 0: |
710 | view->refreshCurrent(); | 720 | view->refreshCurrent(); |
711 | break; | 721 | break; |
712 | case 1: | 722 | case 1: |
713 | deleteAllMail(imap->getWrapper(),folder); | 723 | deleteAllMail(imap->getWrapper(),folder); |
714 | break; | 724 | break; |
715 | case 2: | 725 | case 2: |
716 | createNewFolder(); | 726 | createNewFolder(); |
717 | break; | 727 | break; |
718 | case 3: | 728 | case 3: |
719 | deleteFolder(); | 729 | deleteFolder(); |
720 | break; | 730 | break; |
721 | case 4: | 731 | case 4: |
722 | downloadMails(); | 732 | downloadMails(); |
723 | break; | 733 | break; |
724 | default: | 734 | default: |
725 | break; | 735 | break; |
726 | } | 736 | } |
727 | } | 737 | } |
728 | 738 | ||
729 | /** | 739 | /** |
730 | * MH Account stuff | 740 | * MH Account stuff |
731 | */ | 741 | */ |
732 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 742 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
733 | POP3 and MBOX */ | 743 | POP3 and MBOX */ |
734 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 744 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
735 | : AccountViewItem( parent ) | 745 | : AccountViewItem( parent ) |
736 | { | 746 | { |
737 | m_Path = aPath; | 747 | m_Path = aPath; |
738 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 748 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
739 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 749 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |
740 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 750 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
741 | setText( 0, " Local Folders" ); | 751 | setText( 0, " Local Folders" ); |
742 | setOpen( true ); | 752 | setOpen( true ); |
743 | folder = 0; | 753 | folder = 0; |
744 | } | 754 | } |
745 | 755 | ||
746 | MHviewItem::~MHviewItem() | 756 | MHviewItem::~MHviewItem() |
747 | { | 757 | { |
748 | delete wrapper; | 758 | delete wrapper; |
749 | } | 759 | } |
750 | 760 | ||
751 | AbstractMail *MHviewItem::getWrapper() | 761 | AbstractMail *MHviewItem::getWrapper() |
752 | { | 762 | { |
753 | return wrapper; | 763 | return wrapper; |
754 | } | 764 | } |
755 | 765 | ||
756 | void MHviewItem::refresh( QValueList<RecMailP> & target) | 766 | void MHviewItem::refresh( QValueList<RecMailP> & target) |
757 | { | 767 | { |
758 | refresh(false); | 768 | refresh(false); |
759 | getWrapper()->listMessages( "",target ); | 769 | getWrapper()->listMessages( "",target ); |
760 | } | 770 | } |
761 | 771 | ||
762 | void MHviewItem::refresh(bool force) | 772 | void MHviewItem::refresh(bool force) |
763 | { | 773 | { |
764 | if (childCount()>0 && force==false) return; | 774 | if (childCount()>0 && force==false) return; |
765 | removeChilds(); | 775 | removeChilds(); |
766 | currentFolders.clear(); | 776 | currentFolders.clear(); |
767 | QValueList<FolderP> *folders = wrapper->listFolders(); | 777 | QValueList<FolderP> *folders = wrapper->listFolders(); |
768 | QValueList<FolderP>::ConstIterator it; | 778 | QValueList<FolderP>::ConstIterator it; |
769 | MHfolderItem*item = 0; | 779 | MHfolderItem*item = 0; |
770 | MHfolderItem*pmaster = 0; | 780 | MHfolderItem*pmaster = 0; |
771 | QString fname = ""; | 781 | QString fname = ""; |
772 | int pos; | 782 | int pos; |
773 | for ( it = folders->begin(); it!=folders->end(); ++it) | 783 | for ( it = folders->begin(); it!=folders->end(); ++it) |
774 | { | 784 | { |
775 | fname = (*it)->getDisplayName(); | 785 | fname = (*it)->getDisplayName(); |
776 | /* this folder itself */ | 786 | /* this folder itself */ |
777 | if (fname=="/") | 787 | if (fname=="/") |
778 | { | 788 | { |
779 | currentFolders.append(fname); | 789 | currentFolders.append(fname); |
780 | folder = (*it); | 790 | folder = (*it); |
781 | continue; | 791 | continue; |
782 | } | 792 | } |
783 | currentFolders.append(fname); | 793 | currentFolders.append(fname); |
784 | pos = fname.findRev("/"); | 794 | pos = fname.findRev("/"); |
785 | if (pos > 0) | 795 | if (pos > 0) |
786 | { | 796 | { |
787 | fname = fname.left(pos); | 797 | fname = fname.left(pos); |
788 | pmaster = (MHfolderItem*)findSubItem(fname); | 798 | pmaster = (MHfolderItem*)findSubItem(fname); |
789 | } | 799 | } |
790 | else | 800 | else |
791 | { | 801 | { |
792 | pmaster = 0; | 802 | pmaster = 0; |
793 | } | 803 | } |
794 | if (pmaster) | 804 | if (pmaster) |
795 | { | 805 | { |
796 | item = new MHfolderItem( (*it), pmaster, item, this ); | 806 | item = new MHfolderItem( (*it), pmaster, item, this ); |
797 | } | 807 | } |
798 | else | 808 | else |
799 | { | 809 | { |
800 | item = new MHfolderItem( (*it), this , item ); | 810 | item = new MHfolderItem( (*it), this , item ); |
801 | } | 811 | } |
802 | item->setSelectable((*it)->may_select()); | 812 | item->setSelectable((*it)->may_select()); |
803 | } | 813 | } |
804 | delete folders; | 814 | delete folders; |
805 | } | 815 | } |
806 | 816 | ||
807 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) | 817 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) |
808 | { | 818 | { |
809 | 819 | ||
810 | return wrapper->fetchBody( mail ); | 820 | return wrapper->fetchBody( mail ); |
811 | } | 821 | } |
812 | 822 | ||
813 | QPopupMenu * MHviewItem::getContextMenu() | 823 | QPopupMenu * MHviewItem::getContextMenu() |
814 | { | 824 | { |
815 | QPopupMenu *m = new QPopupMenu(0); | 825 | QPopupMenu *m = new QPopupMenu(0); |
816 | if (m) | 826 | if (m) |
817 | { | 827 | { |
818 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 828 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
819 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 829 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
820 | m->insertItem(QObject::tr("Delete all mails",contextName),2); | 830 | m->insertItem(QObject::tr("Delete all mails",contextName),2); |
821 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); | 831 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); |
822 | } | 832 | } |
823 | return m; | 833 | return m; |
824 | } | 834 | } |
825 | 835 | ||
826 | void MHviewItem::createFolder() | 836 | void MHviewItem::createFolder() |
827 | { | 837 | { |
828 | Newmdirdlg ndirdlg(0,0,true); | 838 | Newmdirdlg ndirdlg(0,0,true); |
829 | ndirdlg.showMaximized(); | 839 | ndirdlg.showMaximized(); |
830 | if ( ndirdlg.exec() ) | 840 | if ( ndirdlg.exec() ) |
831 | { | 841 | { |
832 | QString ndir = ndirdlg.Newdir(); | 842 | QString ndir = ndirdlg.Newdir(); |
833 | if (wrapper->createMbox(ndir)) | 843 | if (wrapper->createMbox(ndir)) |
834 | { | 844 | { |
835 | refresh(true); | 845 | refresh(true); |
836 | } | 846 | } |
837 | } | 847 | } |
838 | } | 848 | } |
839 | 849 | ||
840 | void MHviewItem::downloadMails() | 850 | void MHviewItem::downloadMails() |
841 | { | 851 | { |
842 | AccountView*bl = accountView(); | 852 | AccountView*bl = accountView(); |
843 | if (!bl) return; | 853 | if (!bl) return; |
844 | bl->downloadMails(folder,getWrapper()); | 854 | bl->downloadMails(folder,getWrapper()); |
845 | } | 855 | } |
846 | 856 | ||
847 | QStringList MHviewItem::subFolders() | 857 | QStringList MHviewItem::subFolders() |
848 | { | 858 | { |
849 | return currentFolders; | 859 | return currentFolders; |
850 | } | 860 | } |
851 | 861 | ||
852 | void MHviewItem::contextMenuSelected(int which) | 862 | void MHviewItem::contextMenuSelected(int which) |
853 | { | 863 | { |
854 | switch (which) | 864 | switch (which) |
855 | { | 865 | { |
856 | case 0: | 866 | case 0: |
857 | refresh(true); | 867 | refresh(true); |
858 | break; | 868 | break; |
859 | case 1: | 869 | case 1: |
860 | createFolder(); | 870 | createFolder(); |
861 | break; | 871 | break; |
862 | case 2: | 872 | case 2: |
863 | deleteAllMail(getWrapper(),folder); | 873 | deleteAllMail(getWrapper(),folder); |
864 | break; | 874 | break; |
865 | case 3: | 875 | case 3: |
866 | downloadMails(); | 876 | downloadMails(); |
867 | break; | 877 | break; |
868 | default: | 878 | default: |
869 | break; | 879 | break; |
870 | } | 880 | } |
871 | } | 881 | } |
872 | 882 | ||
873 | MHfolderItem::~MHfolderItem() | 883 | MHfolderItem::~MHfolderItem() |
874 | {} | 884 | {} |
875 | 885 | ||
876 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) | 886 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) |
877 | : AccountViewItem(folderInit, parent,after ) | 887 | : AccountViewItem(folderInit, parent,after ) |
878 | { | 888 | { |
879 | mbox = parent; | 889 | mbox = parent; |
880 | initName(); | 890 | initName(); |
881 | } | 891 | } |
882 | 892 | ||
883 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | 893 | MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) |
884 | : AccountViewItem(folderInit, parent,after ) | 894 | : AccountViewItem(folderInit, parent,after ) |
885 | { | 895 | { |
886 | folder = folderInit; | 896 | folder = folderInit; |
887 | mbox = master; | 897 | mbox = master; |
888 | initName(); | 898 | initName(); |
889 | } | 899 | } |
890 | 900 | ||
891 | void MHfolderItem::initName() | 901 | void MHfolderItem::initName() |
892 | { | 902 | { |
893 | QString bName = folder->getDisplayName(); | 903 | QString bName = folder->getDisplayName(); |
894 | if (bName.startsWith("/")&&bName.length()>1) | 904 | if (bName.startsWith("/")&&bName.length()>1) |
895 | { | 905 | { |
896 | bName.replace(0,1,""); | 906 | bName.replace(0,1,""); |
897 | } | 907 | } |
898 | int pos = bName.findRev("/"); | 908 | int pos = bName.findRev("/"); |
899 | if (pos > 0) | 909 | if (pos > 0) |
900 | { | 910 | { |
901 | bName.replace(0,pos+1,""); | 911 | bName.replace(0,pos+1,""); |
902 | } | 912 | } |
903 | if (bName.lower() == "outgoing") | 913 | if (bName.lower() == "outgoing") |
904 | { | 914 | { |
905 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 915 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
906 | } | 916 | } |
907 | else if (bName.lower() == "inbox") | 917 | else if (bName.lower() == "inbox") |
908 | { | 918 | { |
909 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 919 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
910 | } else if (bName.lower() == "drafts") { | 920 | } else if (bName.lower() == "drafts") { |
911 | setPixmap(0, SmallIcon ("edit")); | 921 | setPixmap(0, SmallIcon ("edit")); |
912 | } else { | 922 | } else { |
913 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 923 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
914 | } | 924 | } |
915 | setText( 0, bName ); | 925 | setText( 0, bName ); |
916 | } | 926 | } |
917 | 927 | ||
918 | const FolderP&MHfolderItem::getFolder()const | 928 | const FolderP&MHfolderItem::getFolder()const |
919 | { | 929 | { |
920 | return folder; | 930 | return folder; |
921 | } | 931 | } |
922 | 932 | ||
923 | void MHfolderItem::refresh(QValueList<RecMailP>&target) | 933 | void MHfolderItem::refresh(QValueList<RecMailP>&target) |
924 | { | 934 | { |
925 | if (folder->may_select()) | 935 | if (folder->may_select()) |
926 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 936 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
927 | } | 937 | } |
928 | 938 | ||
929 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) | 939 | RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) |
930 | { | 940 | { |
931 | return mbox->getWrapper()->fetchBody(aMail); | 941 | return mbox->getWrapper()->fetchBody(aMail); |
932 | } | 942 | } |
933 | 943 | ||
934 | void MHfolderItem::deleteFolder() | 944 | void MHfolderItem::deleteFolder() |
935 | { | 945 | { |
936 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 946 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
937 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 947 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
938 | QObject::tr("Yes",contextName), | 948 | QObject::tr("Yes",contextName), |
939 | QObject::tr("No",contextName),QString::null,1,1); | 949 | QObject::tr("No",contextName),QString::null,1,1); |
940 | 950 | ||
941 | if (yesno == 0) | 951 | if (yesno == 0) |
942 | { | 952 | { |
943 | if (mbox->getWrapper()->deleteMbox(folder)) | 953 | if (mbox->getWrapper()->deleteMbox(folder)) |
944 | { | 954 | { |
945 | QListView*v=listView(); | 955 | QListView*v=listView(); |
946 | MHviewItem * box = mbox; | 956 | MHviewItem * box = mbox; |
947 | /* be carefull - after that this object is destroyd so don't use | 957 | /* be carefull - after that this object is destroyd so don't use |
948 | * any member of it after that call!!*/ | 958 | * any member of it after that call!!*/ |
949 | mbox->refresh(true); | 959 | mbox->refresh(true); |
950 | if (v) | 960 | if (v) |
951 | { | 961 | { |
952 | v->setSelected(box,true); | 962 | v->setSelected(box,true); |
953 | } | 963 | } |
954 | } | 964 | } |
955 | } | 965 | } |
956 | } | 966 | } |
957 | 967 | ||
958 | QPopupMenu * MHfolderItem::getContextMenu() | 968 | QPopupMenu * MHfolderItem::getContextMenu() |
959 | { | 969 | { |
960 | QPopupMenu *m = new QPopupMenu(0); | 970 | QPopupMenu *m = new QPopupMenu(0); |
961 | if (m) | 971 | if (m) |
962 | { | 972 | { |
963 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 973 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
964 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | 974 | m->insertItem(QObject::tr("Delete all mails",contextName),0); |
965 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); | 975 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); |
966 | m->insertItem(QObject::tr("Delete folder",contextName),1); | 976 | m->insertItem(QObject::tr("Delete folder",contextName),1); |
967 | } | 977 | } |
968 | return m; | 978 | return m; |
969 | } | 979 | } |
970 | 980 | ||
971 | void MHfolderItem::downloadMails() | 981 | void MHfolderItem::downloadMails() |
972 | { | 982 | { |
973 | AccountView*bl = mbox->accountView(); | 983 | AccountView*bl = mbox->accountView(); |
974 | if (!bl) return; | 984 | if (!bl) return; |
975 | bl->downloadMails(folder,mbox->getWrapper()); | 985 | bl->downloadMails(folder,mbox->getWrapper()); |
976 | } | 986 | } |
977 | 987 | ||
978 | void MHfolderItem::createFolder() | 988 | void MHfolderItem::createFolder() |
979 | { | 989 | { |
980 | Newmdirdlg ndirdlg(0,0,true); | 990 | Newmdirdlg ndirdlg(0,0,true); |
981 | ndirdlg.showMaximized(); | 991 | ndirdlg.showMaximized(); |
982 | if (ndirdlg.exec() ) | 992 | if (ndirdlg.exec() ) |
983 | { | 993 | { |
984 | QString ndir = ndirdlg.Newdir(); | 994 | QString ndir = ndirdlg.Newdir(); |
985 | if (mbox->getWrapper()->createMbox(ndir,folder)) | 995 | if (mbox->getWrapper()->createMbox(ndir,folder)) |
986 | { | 996 | { |
987 | QListView*v=listView(); | 997 | QListView*v=listView(); |
988 | MHviewItem * box = mbox; | 998 | MHviewItem * box = mbox; |
989 | /* be carefull - after that this object is destroyd so don't use | 999 | /* be carefull - after that this object is destroyd so don't use |
990 | * any member of it after that call!!*/ | 1000 | * any member of it after that call!!*/ |
991 | mbox->refresh(true); | 1001 | mbox->refresh(true); |
992 | if (v) | 1002 | if (v) |
993 | { | 1003 | { |
994 | v->setSelected(box,true); | 1004 | v->setSelected(box,true); |
995 | } | 1005 | } |
996 | } | 1006 | } |
997 | } | 1007 | } |
998 | } | 1008 | } |
999 | 1009 | ||
1000 | void MHfolderItem::contextMenuSelected(int which) | 1010 | void MHfolderItem::contextMenuSelected(int which) |
1001 | { | 1011 | { |
1002 | switch(which) | 1012 | switch(which) |
1003 | { | 1013 | { |
1004 | case 0: | 1014 | case 0: |
1005 | deleteAllMail(mbox->getWrapper(),folder); | 1015 | deleteAllMail(mbox->getWrapper(),folder); |
1006 | break; | 1016 | break; |
1007 | case 1: | 1017 | case 1: |
1008 | deleteFolder(); | 1018 | deleteFolder(); |
1009 | break; | 1019 | break; |
1010 | case 2: | 1020 | case 2: |
1011 | downloadMails(); | 1021 | downloadMails(); |
1012 | break; | 1022 | break; |
1013 | case 3: | 1023 | case 3: |
1014 | createFolder(); | 1024 | createFolder(); |
1015 | break; | 1025 | break; |
1016 | default: | 1026 | default: |
1017 | break; | 1027 | break; |
1018 | } | 1028 | } |
1019 | } | 1029 | } |
1020 | 1030 | ||
1021 | bool MHfolderItem::isDraftfolder() | 1031 | bool MHfolderItem::isDraftfolder() |
1022 | { | 1032 | { |
1023 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; | 1033 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; |
1024 | return false; | 1034 | return false; |
1025 | } | 1035 | } |
1026 | 1036 | ||
1027 | /** | 1037 | /** |
1028 | * Generic stuff | 1038 | * Generic stuff |
1029 | */ | 1039 | */ |
1030 | 1040 | ||
1031 | const QString AccountViewItem::contextName="AccountViewItem"; | 1041 | const QString AccountViewItem::contextName="AccountViewItem"; |
1032 | 1042 | ||
1033 | AccountViewItem::AccountViewItem( AccountView *parent ) | 1043 | AccountViewItem::AccountViewItem( AccountView *parent ) |
1034 | : QListViewItem( parent ) | 1044 | : QListViewItem( parent ) |
1035 | { | 1045 | { |
1036 | init(); | 1046 | init(); |
1037 | m_Backlink = parent; | 1047 | m_Backlink = parent; |
1038 | } | 1048 | } |
1039 | 1049 | ||
1040 | AccountViewItem::AccountViewItem( QListViewItem *parent) | 1050 | AccountViewItem::AccountViewItem( QListViewItem *parent) |
1041 | : QListViewItem( parent),folder(0) | 1051 | : QListViewItem( parent),folder(0) |
1042 | { | 1052 | { |
1043 | init(); | 1053 | init(); |
1044 | } | 1054 | } |
1045 | 1055 | ||
1046 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | 1056 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) |
1047 | :QListViewItem( parent,after ),folder(0) | 1057 | :QListViewItem( parent,after ),folder(0) |
1048 | { | 1058 | { |
1049 | init(); | 1059 | init(); |
1050 | } | 1060 | } |
1051 | 1061 | ||
1052 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) | 1062 | AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) |
1053 | :QListViewItem( parent,after ),folder(folderInit) | 1063 | :QListViewItem( parent,after ),folder(folderInit) |
1054 | { | 1064 | { |
1055 | init(); | 1065 | init(); |
1056 | } | 1066 | } |
1057 | 1067 | ||
1058 | void AccountViewItem::init() | 1068 | void AccountViewItem::init() |
1059 | { | 1069 | { |
1060 | m_Backlink = 0; | 1070 | m_Backlink = 0; |
1061 | } | 1071 | } |
1062 | 1072 | ||
1063 | AccountViewItem::~AccountViewItem() | 1073 | AccountViewItem::~AccountViewItem() |
1064 | { | 1074 | { |
1065 | folder = 0; | 1075 | folder = 0; |
1066 | } | 1076 | } |
1067 | 1077 | ||
1068 | AccountView*AccountViewItem::accountView() | 1078 | AccountView*AccountViewItem::accountView() |
1069 | { | 1079 | { |
1070 | return m_Backlink; | 1080 | return m_Backlink; |
1071 | } | 1081 | } |
1072 | 1082 | ||
1073 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) | 1083 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) |
1074 | { | 1084 | { |
1075 | if (!wrapper) return; | 1085 | if (!wrapper) return; |
1076 | QString fname=""; | 1086 | QString fname=""; |
1077 | if (folder) fname = folder->getDisplayName(); | 1087 | if (folder) fname = folder->getDisplayName(); |
1078 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | 1088 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), |
1079 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). | 1089 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). |
1080 | arg(fname), | 1090 | arg(fname), |
1081 | QObject::tr("Yes",contextName), | 1091 | QObject::tr("Yes",contextName), |
1082 | QObject::tr("No",contextName),QString::null,1,1); | 1092 | QObject::tr("No",contextName),QString::null,1,1); |
1083 | 1093 | ||
1084 | if (yesno == 0) | 1094 | if (yesno == 0) |
1085 | { | 1095 | { |
1086 | if (wrapper->deleteAllMail(folder)) | 1096 | if (wrapper->deleteAllMail(folder)) |
1087 | { | 1097 | { |
1088 | AccountView * view = (AccountView*)listView(); | 1098 | AccountView * view = (AccountView*)listView(); |
1089 | if (view) view->refreshCurrent(); | 1099 | if (view) view->refreshCurrent(); |
1090 | } | 1100 | } |
1091 | } | 1101 | } |
1092 | } | 1102 | } |
1093 | 1103 | ||
1094 | void AccountViewItem::removeChilds() | 1104 | void AccountViewItem::removeChilds() |
1095 | { | 1105 | { |
1096 | QListViewItem *child = firstChild(); | 1106 | QListViewItem *child = firstChild(); |
1097 | while ( child ) | 1107 | while ( child ) |
1098 | { | 1108 | { |
1099 | QListViewItem *tmp = child; | 1109 | QListViewItem *tmp = child; |
1100 | child = child->nextSibling(); | 1110 | child = child->nextSibling(); |
1101 | delete tmp; | 1111 | delete tmp; |
1102 | } | 1112 | } |
1103 | } | 1113 | } |
1104 | 1114 | ||
1105 | bool AccountViewItem::matchName(const QString&name)const | 1115 | bool AccountViewItem::matchName(const QString&name)const |
1106 | { | 1116 | { |
1107 | if (!folder) return false; | 1117 | if (!folder) return false; |
1108 | return folder->getDisplayName()==name; | 1118 | return folder->getDisplayName().lower()==name.lower(); |
1109 | } | 1119 | } |
1110 | 1120 | ||
1111 | 1121 | ||
1112 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) | 1122 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) |
1113 | { | 1123 | { |
1114 | AccountViewItem*pitem,*sitem; | 1124 | AccountViewItem*pitem,*sitem; |
1115 | if (!start) pitem = (AccountViewItem*)firstChild(); | 1125 | if (!start) pitem = (AccountViewItem*)firstChild(); |
1116 | else pitem = (AccountViewItem*)start->firstChild(); | 1126 | else pitem = (AccountViewItem*)start->firstChild(); |
1117 | while (pitem) | 1127 | while (pitem) |
1118 | { | 1128 | { |
1119 | if (pitem->matchName(path)) | 1129 | if (pitem->matchName(path)) |
1120 | { | 1130 | { |
1121 | break; | 1131 | break; |
1122 | } | 1132 | } |
1123 | if (pitem->childCount()>0) | 1133 | if (pitem->childCount()>0) |
1124 | { | 1134 | { |
1125 | sitem = findSubItem(path,pitem); | 1135 | sitem = findSubItem(path,pitem); |
1126 | if (sitem) | 1136 | if (sitem) |
1127 | { | 1137 | { |
1128 | pitem = sitem; | 1138 | pitem = sitem; |
1129 | break; | 1139 | break; |
1130 | } | 1140 | } |
1131 | } | 1141 | } |
1132 | pitem=(AccountViewItem*)pitem->nextSibling(); | 1142 | pitem=(AccountViewItem*)pitem->nextSibling(); |
1133 | } | 1143 | } |
1134 | return pitem; | 1144 | return pitem; |
1135 | } | 1145 | } |
1136 | 1146 | ||
1137 | bool AccountViewItem::isDraftfolder() | 1147 | bool AccountViewItem::isDraftfolder() |
1138 | { | 1148 | { |
1139 | return false; | 1149 | return false; |
1140 | } | 1150 | } |