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