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