Diffstat (limited to 'noncore/net/mail/accountitem.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/accountitem.cpp | 133 |
1 files changed, 75 insertions, 58 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index c1574fd..4869df8 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp | |||
@@ -81,30 +81,30 @@ RECBODYP POP3viewItem::fetchBody( const RecMailP &mail ) | |||
81 | { | 81 | { |
82 | odebug << "POP3 fetchBody" << oendl; | 82 | odebug << "POP3 fetchBody" << oendl; |
83 | return wrapper->fetchBody( mail ); | 83 | return wrapper->fetchBody( mail ); |
84 | } | 84 | } |
85 | 85 | ||
86 | QPopupMenu * POP3viewItem::getContextMenu() | 86 | QPopupMenu * POP3viewItem::getContextMenu() |
87 | { | 87 | { |
88 | QPopupMenu *m = new QPopupMenu(0); | 88 | QPopupMenu *m = new QPopupMenu(0); |
89 | if (m) | 89 | if (m) |
90 | { | 90 | { |
91 | if (!account->getOffline()) | 91 | if (!account->getOffline()) |
92 | { | 92 | { |
93 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 93 | m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); |
94 | m->insertItem(QObject::tr("Set offline",contextName),1); | 94 | m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); |
95 | } | 95 | } |
96 | else | 96 | else |
97 | { | 97 | { |
98 | m->insertItem(QObject::tr("Set online",contextName),1); | 98 | m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | return m; | 101 | return m; |
102 | } | 102 | } |
103 | 103 | ||
104 | void POP3viewItem::disconnect() | 104 | void POP3viewItem::disconnect() |
105 | { | 105 | { |
106 | QListViewItem *child = firstChild(); | 106 | QListViewItem *child = firstChild(); |
107 | while ( child ) | 107 | while ( child ) |
108 | { | 108 | { |
109 | QListViewItem *tmp = child; | 109 | QListViewItem *tmp = child; |
110 | child = child->nextSibling(); | 110 | child = child->nextSibling(); |
@@ -120,28 +120,28 @@ void POP3viewItem::setOnOffline() | |||
120 | disconnect(); | 120 | disconnect(); |
121 | } | 121 | } |
122 | account->setOffline(!account->getOffline()); | 122 | account->setOffline(!account->getOffline()); |
123 | account->save(); | 123 | account->save(); |
124 | SETPIX(PIXMAP_POP3FOLDER); | 124 | SETPIX(PIXMAP_POP3FOLDER); |
125 | refresh(); | 125 | refresh(); |
126 | } | 126 | } |
127 | 127 | ||
128 | void POP3viewItem::contextMenuSelected(int which) | 128 | void POP3viewItem::contextMenuSelected(int which) |
129 | { | 129 | { |
130 | switch (which) | 130 | switch (which) |
131 | { | 131 | { |
132 | case 0: | 132 | case SERVER_MENU_DISCONNECT: |
133 | disconnect(); | 133 | disconnect(); |
134 | break; | 134 | break; |
135 | case 1: | 135 | case SERVER_MENU_OFFLINE: |
136 | setOnOffline(); | 136 | setOnOffline(); |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | POP3folderItem::~POP3folderItem() | 141 | POP3folderItem::~POP3folderItem() |
142 | {} | 142 | {} |
143 | 143 | ||
144 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) | 144 | POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) |
145 | : AccountViewItem(folderInit,parent,after ) | 145 | : AccountViewItem(folderInit,parent,after ) |
146 | { | 146 | { |
147 | pop3 = parent; | 147 | pop3 = parent; |
@@ -163,52 +163,52 @@ void POP3folderItem::refresh(QValueList<RecMailP>&target) | |||
163 | } | 163 | } |
164 | 164 | ||
165 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) | 165 | RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) |
166 | { | 166 | { |
167 | return pop3->getWrapper()->fetchBody(aMail); | 167 | return pop3->getWrapper()->fetchBody(aMail); |
168 | } | 168 | } |
169 | 169 | ||
170 | QPopupMenu * POP3folderItem::getContextMenu() | 170 | QPopupMenu * POP3folderItem::getContextMenu() |
171 | { | 171 | { |
172 | QPopupMenu *m = new QPopupMenu(0); | 172 | QPopupMenu *m = new QPopupMenu(0); |
173 | if (m) | 173 | if (m) |
174 | { | 174 | { |
175 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 175 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); |
176 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 176 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); |
177 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 177 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); |
178 | } | 178 | } |
179 | return m; | 179 | return m; |
180 | } | 180 | } |
181 | 181 | ||
182 | void POP3folderItem::downloadMails() | 182 | void POP3folderItem::downloadMails() |
183 | { | 183 | { |
184 | AccountView*bl = pop3->accountView(); | 184 | AccountView*bl = pop3->accountView(); |
185 | if (!bl) return; | 185 | if (!bl) return; |
186 | bl->downloadMails(folder,pop3->getWrapper()); | 186 | bl->downloadMails(folder,pop3->getWrapper()); |
187 | } | 187 | } |
188 | 188 | ||
189 | void POP3folderItem::contextMenuSelected(int which) | 189 | void POP3folderItem::contextMenuSelected(int which) |
190 | { | 190 | { |
191 | AccountView * view = (AccountView*)listView(); | 191 | AccountView * view = (AccountView*)listView(); |
192 | switch (which) | 192 | switch (which) |
193 | { | 193 | { |
194 | case 0: | 194 | case FOLDER_MENU_REFRESH_HEADER: |
195 | /* must be 'cause pop3 lists are cached */ | 195 | /* must be 'cause pop3 lists are cached */ |
196 | pop3->getWrapper()->logout(); | 196 | pop3->getWrapper()->logout(); |
197 | view->refreshCurrent(); | 197 | view->refreshCurrent(); |
198 | break; | 198 | break; |
199 | case 1: | 199 | case FOLDER_MENU_DELETE_ALL_MAILS: |
200 | deleteAllMail(pop3->getWrapper(),folder); | 200 | deleteAllMail(pop3->getWrapper(),folder); |
201 | break; | 201 | break; |
202 | case 2: | 202 | case FOLDER_MENU_MOVE_MAILS: |
203 | downloadMails(); | 203 | downloadMails(); |
204 | break; | 204 | break; |
205 | default: | 205 | default: |
206 | break; | 206 | break; |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | /** | 210 | /** |
211 | * NNTP Account stuff | 211 | * NNTP Account stuff |
212 | */ | 212 | */ |
213 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 213 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
214 | : AccountViewItem( parent ) | 214 | : AccountViewItem( parent ) |
@@ -272,31 +272,31 @@ RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) | |||
272 | { | 272 | { |
273 | odebug << "NNTP fetchBody" << oendl; | 273 | odebug << "NNTP fetchBody" << oendl; |
274 | return wrapper->fetchBody( mail ); | 274 | return wrapper->fetchBody( mail ); |
275 | } | 275 | } |
276 | 276 | ||
277 | QPopupMenu * NNTPviewItem::getContextMenu() | 277 | QPopupMenu * NNTPviewItem::getContextMenu() |
278 | { | 278 | { |
279 | QPopupMenu *m = new QPopupMenu(0); | 279 | QPopupMenu *m = new QPopupMenu(0); |
280 | if (m) | 280 | if (m) |
281 | { | 281 | { |
282 | if (!account->getOffline()) | 282 | if (!account->getOffline()) |
283 | { | 283 | { |
284 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 284 | m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); |
285 | m->insertItem(QObject::tr("Set offline",contextName),1); | 285 | m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); |
286 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2); | 286 | m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),SERVER_MENU_SUBSCRIBE); |
287 | } | 287 | } |
288 | else | 288 | else |
289 | { | 289 | { |
290 | m->insertItem(QObject::tr("Set online",contextName),1); | 290 | m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | return m; | 293 | return m; |
294 | } | 294 | } |
295 | 295 | ||
296 | void NNTPviewItem::subscribeGroups() | 296 | void NNTPviewItem::subscribeGroups() |
297 | { | 297 | { |
298 | NNTPGroupsDlg dlg(account); | 298 | NNTPGroupsDlg dlg(account); |
299 | if (QPEApplication::execDialog(&dlg)== QDialog::Accepted ){ | 299 | if (QPEApplication::execDialog(&dlg)== QDialog::Accepted ){ |
300 | refresh(); | 300 | refresh(); |
301 | } | 301 | } |
302 | } | 302 | } |
@@ -321,31 +321,31 @@ void NNTPviewItem::setOnOffline() | |||
321 | } | 321 | } |
322 | account->setOffline(!account->getOffline()); | 322 | account->setOffline(!account->getOffline()); |
323 | account->save(); | 323 | account->save(); |
324 | //FIXME | 324 | //FIXME |
325 | SETPIX(PIXMAP_POP3FOLDER); | 325 | SETPIX(PIXMAP_POP3FOLDER); |
326 | refresh(); | 326 | refresh(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void NNTPviewItem::contextMenuSelected(int which) | 329 | void NNTPviewItem::contextMenuSelected(int which) |
330 | { | 330 | { |
331 | switch (which) | 331 | switch (which) |
332 | { | 332 | { |
333 | case 0: | 333 | case SERVER_MENU_DISCONNECT: |
334 | disconnect(); | 334 | disconnect(); |
335 | break; | 335 | break; |
336 | case 1: | 336 | case SERVER_MENU_OFFLINE: |
337 | setOnOffline(); | 337 | setOnOffline(); |
338 | break; | 338 | break; |
339 | case 2: | 339 | case SERVER_MENU_SUBSCRIBE: |
340 | subscribeGroups(); | 340 | subscribeGroups(); |
341 | break; | 341 | break; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | NNTPfolderItem::~NNTPfolderItem() | 345 | NNTPfolderItem::~NNTPfolderItem() |
346 | {} | 346 | {} |
347 | 347 | ||
348 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) | 348 | NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) |
349 | : AccountViewItem( folderInit, parent,after ) | 349 | : AccountViewItem( folderInit, parent,after ) |
350 | { | 350 | { |
351 | nntp = parent; | 351 | nntp = parent; |
@@ -367,48 +367,48 @@ void NNTPfolderItem::refresh(QValueList<RecMailP>&target) | |||
367 | } | 367 | } |
368 | 368 | ||
369 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) | 369 | RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) |
370 | { | 370 | { |
371 | return nntp->getWrapper()->fetchBody(aMail); | 371 | return nntp->getWrapper()->fetchBody(aMail); |
372 | } | 372 | } |
373 | 373 | ||
374 | QPopupMenu * NNTPfolderItem::getContextMenu() | 374 | QPopupMenu * NNTPfolderItem::getContextMenu() |
375 | { | 375 | { |
376 | QPopupMenu *m = new QPopupMenu(0); | 376 | QPopupMenu *m = new QPopupMenu(0); |
377 | if (m) | 377 | if (m) |
378 | { | 378 | { |
379 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 379 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); |
380 | m->insertItem(QObject::tr("Copy all postings",contextName),1); | 380 | m->insertItem(QObject::tr("Copy all postings",contextName),FOLDER_MENU_MOVE_MAILS); |
381 | } | 381 | } |
382 | return m; | 382 | return m; |
383 | } | 383 | } |
384 | 384 | ||
385 | void NNTPfolderItem::downloadMails() | 385 | void NNTPfolderItem::downloadMails() |
386 | { | 386 | { |
387 | AccountView*bl = nntp->accountView(); | 387 | AccountView*bl = nntp->accountView(); |
388 | if (!bl) return; | 388 | if (!bl) return; |
389 | bl->downloadMails(folder,nntp->getWrapper()); | 389 | bl->downloadMails(folder,nntp->getWrapper()); |
390 | } | 390 | } |
391 | 391 | ||
392 | void NNTPfolderItem::contextMenuSelected(int which) | 392 | void NNTPfolderItem::contextMenuSelected(int which) |
393 | { | 393 | { |
394 | AccountView * view = (AccountView*)listView(); | 394 | AccountView * view = (AccountView*)listView(); |
395 | switch (which) | 395 | switch (which) |
396 | { | 396 | { |
397 | case 0: | 397 | case FOLDER_MENU_REFRESH_HEADER: |
398 | /* must be 'cause pop3 lists are cached */ | 398 | /* must be 'cause nntp lists are cached */ |
399 | nntp->getWrapper()->logout(); | 399 | nntp->getWrapper()->logout(); |
400 | view->refreshCurrent(); | 400 | view->refreshCurrent(); |
401 | break; | 401 | break; |
402 | case 1: | 402 | case FOLDER_MENU_MOVE_MAILS: |
403 | downloadMails(); | 403 | downloadMails(); |
404 | break; | 404 | break; |
405 | default: | 405 | default: |
406 | break; | 406 | break; |
407 | } | 407 | } |
408 | } | 408 | } |
409 | 409 | ||
410 | /** | 410 | /** |
411 | * IMAP Account stuff | 411 | * IMAP Account stuff |
412 | */ | 412 | */ |
413 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 413 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
414 | : AccountViewItem( parent ) | 414 | : AccountViewItem( parent ) |
@@ -489,33 +489,33 @@ void IMAPviewItem::refreshFolders(bool force) | |||
489 | } | 489 | } |
490 | } | 490 | } |
491 | delete folders; | 491 | delete folders; |
492 | } | 492 | } |
493 | 493 | ||
494 | QPopupMenu * IMAPviewItem::getContextMenu() | 494 | QPopupMenu * IMAPviewItem::getContextMenu() |
495 | { | 495 | { |
496 | QPopupMenu *m = new QPopupMenu(0); | 496 | QPopupMenu *m = new QPopupMenu(0); |
497 | if (m) | 497 | if (m) |
498 | { | 498 | { |
499 | if (!account->getOffline()) | 499 | if (!account->getOffline()) |
500 | { | 500 | { |
501 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 501 | m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT); |
502 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 502 | m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); |
503 | m->insertSeparator(); | 503 | m->insertSeparator(); |
504 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 504 | m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); |
505 | m->insertItem(QObject::tr("Set offline",contextName),3); | 505 | m->insertItem(QObject::tr("Create new folder",contextName),SERVER_MENU_CREATE_FOLDER); |
506 | } | 506 | } |
507 | else | 507 | else |
508 | { | 508 | { |
509 | m->insertItem(QObject::tr("Set online",contextName),3); | 509 | m->insertItem(QObject::tr("Set online",contextName),SERVER_MENU_OFFLINE); |
510 | } | 510 | } |
511 | } | 511 | } |
512 | return m; | 512 | return m; |
513 | } | 513 | } |
514 | 514 | ||
515 | void IMAPviewItem::createNewFolder() | 515 | void IMAPviewItem::createNewFolder() |
516 | { | 516 | { |
517 | Newmdirdlg ndirdlg; | 517 | Newmdirdlg ndirdlg; |
518 | if ( QPEApplication::execDialog( &ndirdlg )) | 518 | if ( QPEApplication::execDialog( &ndirdlg )) |
519 | { | 519 | { |
520 | QString ndir = ndirdlg.Newdir(); | 520 | QString ndir = ndirdlg.Newdir(); |
521 | bool makesubs = ndirdlg.subpossible(); | 521 | bool makesubs = ndirdlg.subpossible(); |
@@ -528,35 +528,35 @@ void IMAPviewItem::createNewFolder() | |||
528 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 528 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
529 | { | 529 | { |
530 | refreshFolders(true); | 530 | refreshFolders(true); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | } | 533 | } |
534 | 534 | ||
535 | void IMAPviewItem::contextMenuSelected(int id) | 535 | void IMAPviewItem::contextMenuSelected(int id) |
536 | { | 536 | { |
537 | odebug << "Id selected: " << id << "" << oendl; | 537 | odebug << "Id selected: " << id << "" << oendl; |
538 | switch (id) | 538 | switch (id) |
539 | { | 539 | { |
540 | case 0: | 540 | case SERVER_MENU_REFRESH_FOLDER: |
541 | refreshFolders(true); | 541 | refreshFolders(true); |
542 | break; | 542 | break; |
543 | case 1: | 543 | case SERVER_MENU_CREATE_FOLDER: |
544 | createNewFolder(); | 544 | createNewFolder(); |
545 | break; | 545 | break; |
546 | case 2: | 546 | case SERVER_MENU_DISCONNECT: |
547 | removeChilds(); | 547 | removeChilds(); |
548 | wrapper->logout(); | 548 | wrapper->logout(); |
549 | break; | 549 | break; |
550 | case 3: | 550 | case SERVER_MENU_OFFLINE: |
551 | if (account->getOffline()==false) | 551 | if (account->getOffline()==false) |
552 | { | 552 | { |
553 | removeChilds(); | 553 | removeChilds(); |
554 | wrapper->logout(); | 554 | wrapper->logout(); |
555 | } | 555 | } |
556 | account->setOffline(!account->getOffline()); | 556 | account->setOffline(!account->getOffline()); |
557 | account->save(); | 557 | account->save(); |
558 | SETPIX(PIXMAP_IMAPFOLDER); | 558 | SETPIX(PIXMAP_IMAPFOLDER); |
559 | refreshFolders(false); | 559 | refreshFolders(false); |
560 | break; | 560 | break; |
561 | default: | 561 | default: |
562 | break; | 562 | break; |
@@ -626,35 +626,35 @@ void IMAPfolderItem::refresh(QValueList<RecMailP>&target) | |||
626 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) | 626 | RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) |
627 | { | 627 | { |
628 | return imap->getWrapper()->fetchBody(aMail); | 628 | return imap->getWrapper()->fetchBody(aMail); |
629 | } | 629 | } |
630 | 630 | ||
631 | QPopupMenu * IMAPfolderItem::getContextMenu() | 631 | QPopupMenu * IMAPfolderItem::getContextMenu() |
632 | { | 632 | { |
633 | QPopupMenu *m = new QPopupMenu(0); | 633 | QPopupMenu *m = new QPopupMenu(0); |
634 | if (m) | 634 | if (m) |
635 | { | 635 | { |
636 | if (folder->may_select()) | 636 | if (folder->may_select()) |
637 | { | 637 | { |
638 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 638 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); |
639 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | 639 | m->insertItem(QObject::tr("Move/Copy all mails",contextName),FOLDER_MENU_MOVE_MAILS); |
640 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 640 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); |
641 | } | 641 | } |
642 | if (folder->no_inferior()==false) | 642 | if (folder->no_inferior()==false) |
643 | { | 643 | { |
644 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 644 | m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); |
645 | } | 645 | } |
646 | if (folder->getDisplayName().lower()!="inbox") | 646 | if (folder->getDisplayName().lower()!="inbox") |
647 | { | 647 | { |
648 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 648 | m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); |
649 | } | 649 | } |
650 | } | 650 | } |
651 | return m; | 651 | return m; |
652 | } | 652 | } |
653 | 653 | ||
654 | void IMAPfolderItem::createNewFolder() | 654 | void IMAPfolderItem::createNewFolder() |
655 | { | 655 | { |
656 | Newmdirdlg ndirdlg; | 656 | Newmdirdlg ndirdlg; |
657 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 657 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
658 | { | 658 | { |
659 | QString ndir = ndirdlg.Newdir(); | 659 | QString ndir = ndirdlg.Newdir(); |
660 | bool makesubs = ndirdlg.subpossible(); | 660 | bool makesubs = ndirdlg.subpossible(); |
@@ -694,37 +694,41 @@ void IMAPfolderItem::downloadMails() | |||
694 | { | 694 | { |
695 | AccountView*bl = imap->accountView(); | 695 | AccountView*bl = imap->accountView(); |
696 | if (!bl) return; | 696 | if (!bl) return; |
697 | bl->downloadMails(folder,imap->getWrapper()); | 697 | bl->downloadMails(folder,imap->getWrapper()); |
698 | } | 698 | } |
699 | 699 | ||
700 | void IMAPfolderItem::contextMenuSelected(int id) | 700 | void IMAPfolderItem::contextMenuSelected(int id) |
701 | { | 701 | { |
702 | odebug << "Selected id: " << id << "" << oendl; | 702 | odebug << "Selected id: " << id << "" << oendl; |
703 | AccountView * view = (AccountView*)listView(); | 703 | AccountView * view = (AccountView*)listView(); |
704 | switch(id) | 704 | switch(id) |
705 | { | 705 | { |
706 | case 0: | 706 | case FOLDER_MENU_REFRESH_HEADER: |
707 | view->refreshCurrent(); | 707 | view->refreshCurrent(); |
708 | break; | 708 | break; |
709 | case 1: | 709 | case FOLDER_MENU_DELETE_ALL_MAILS: |
710 | deleteAllMail(imap->getWrapper(),folder); | 710 | deleteAllMail(imap->getWrapper(),folder); |
711 | break; | 711 | break; |
712 | case 2: | 712 | case FOLDER_MENU_NEW_SUBFOLDER: |
713 | if (folder->no_inferior()==false) { | ||
713 | createNewFolder(); | 714 | createNewFolder(); |
715 | } | ||
714 | break; | 716 | break; |
715 | case 3: | 717 | case FOLDER_MENU_DELETE_FOLDER: |
718 | if (folder->getDisplayName().lower()!="inbox") { | ||
716 | deleteFolder(); | 719 | deleteFolder(); |
720 | } | ||
717 | break; | 721 | break; |
718 | case 4: | 722 | case FOLDER_MENU_MOVE_MAILS: |
719 | downloadMails(); | 723 | downloadMails(); |
720 | break; | 724 | break; |
721 | default: | 725 | default: |
722 | break; | 726 | break; |
723 | } | 727 | } |
724 | } | 728 | } |
725 | 729 | ||
726 | /** | 730 | /** |
727 | * MH Account stuff | 731 | * MH Account stuff |
728 | */ | 732 | */ |
729 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 733 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
730 | POP3 and MBOX */ | 734 | POP3 and MBOX */ |
@@ -750,24 +754,25 @@ AbstractMail *MHviewItem::getWrapper() | |||
750 | return wrapper; | 754 | return wrapper; |
751 | } | 755 | } |
752 | 756 | ||
753 | void MHviewItem::refresh( QValueList<RecMailP> & target) | 757 | void MHviewItem::refresh( QValueList<RecMailP> & target) |
754 | { | 758 | { |
755 | refresh(false); | 759 | refresh(false); |
756 | getWrapper()->listMessages( "",target ); | 760 | getWrapper()->listMessages( "",target ); |
757 | } | 761 | } |
758 | 762 | ||
759 | void MHviewItem::refresh(bool force) | 763 | void MHviewItem::refresh(bool force) |
760 | { | 764 | { |
761 | if (childCount()>0 && force==false) return; | 765 | if (childCount()>0 && force==false) return; |
766 | odebug << "Refresh mh folders" << oendl; | ||
762 | removeChilds(); | 767 | removeChilds(); |
763 | currentFolders.clear(); | 768 | currentFolders.clear(); |
764 | QValueList<FolderP> *folders = wrapper->listFolders(); | 769 | QValueList<FolderP> *folders = wrapper->listFolders(); |
765 | QValueList<FolderP>::ConstIterator it; | 770 | QValueList<FolderP>::ConstIterator it; |
766 | MHfolderItem*item = 0; | 771 | MHfolderItem*item = 0; |
767 | MHfolderItem*pmaster = 0; | 772 | MHfolderItem*pmaster = 0; |
768 | QString fname = ""; | 773 | QString fname = ""; |
769 | int pos; | 774 | int pos; |
770 | for ( it = folders->begin(); it!=folders->end(); ++it) | 775 | for ( it = folders->begin(); it!=folders->end(); ++it) |
771 | { | 776 | { |
772 | fname = (*it)->getDisplayName(); | 777 | fname = (*it)->getDisplayName(); |
773 | /* this folder itself */ | 778 | /* this folder itself */ |
@@ -803,28 +808,28 @@ void MHviewItem::refresh(bool force) | |||
803 | 808 | ||
804 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) | 809 | RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) |
805 | { | 810 | { |
806 | odebug << "MH fetchBody" << oendl; | 811 | odebug << "MH fetchBody" << oendl; |
807 | return wrapper->fetchBody( mail ); | 812 | return wrapper->fetchBody( mail ); |
808 | } | 813 | } |
809 | 814 | ||
810 | QPopupMenu * MHviewItem::getContextMenu() | 815 | QPopupMenu * MHviewItem::getContextMenu() |
811 | { | 816 | { |
812 | QPopupMenu *m = new QPopupMenu(0); | 817 | QPopupMenu *m = new QPopupMenu(0); |
813 | if (m) | 818 | if (m) |
814 | { | 819 | { |
815 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 820 | m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); |
816 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 821 | m->insertItem(QObject::tr("Create new folder",contextName),FOLDER_MENU_NEW_SUBFOLDER); |
817 | m->insertItem(QObject::tr("Delete all mails",contextName),2); | 822 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); |
818 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); | 823 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); |
819 | } | 824 | } |
820 | return m; | 825 | return m; |
821 | } | 826 | } |
822 | 827 | ||
823 | void MHviewItem::createFolder() | 828 | void MHviewItem::createFolder() |
824 | { | 829 | { |
825 | Newmdirdlg ndirdlg(0,0,true); | 830 | Newmdirdlg ndirdlg(0,0,true); |
826 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 831 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
827 | { | 832 | { |
828 | QString ndir = ndirdlg.Newdir(); | 833 | QString ndir = ndirdlg.Newdir(); |
829 | if (wrapper->createMbox(ndir)) | 834 | if (wrapper->createMbox(ndir)) |
830 | { | 835 | { |
@@ -838,38 +843,44 @@ void MHviewItem::downloadMails() | |||
838 | AccountView*bl = accountView(); | 843 | AccountView*bl = accountView(); |
839 | if (!bl) return; | 844 | if (!bl) return; |
840 | bl->downloadMails(folder,getWrapper()); | 845 | bl->downloadMails(folder,getWrapper()); |
841 | } | 846 | } |
842 | 847 | ||
843 | QStringList MHviewItem::subFolders() | 848 | QStringList MHviewItem::subFolders() |
844 | { | 849 | { |
845 | return currentFolders; | 850 | return currentFolders; |
846 | } | 851 | } |
847 | 852 | ||
848 | void MHviewItem::contextMenuSelected(int which) | 853 | void MHviewItem::contextMenuSelected(int which) |
849 | { | 854 | { |
855 | AccountView*view = 0; | ||
856 | |||
850 | switch (which) | 857 | switch (which) |
851 | { | 858 | { |
852 | case 0: | 859 | case SERVER_MENU_REFRESH_FOLDER: |
853 | refresh(true); | 860 | refresh(true); |
854 | break; | 861 | break; |
855 | case 1: | 862 | case FOLDER_MENU_NEW_SUBFOLDER: |
856 | createFolder(); | 863 | createFolder(); |
857 | break; | 864 | break; |
858 | case 2: | 865 | case FOLDER_MENU_DELETE_ALL_MAILS: |
859 | deleteAllMail(getWrapper(),folder); | 866 | deleteAllMail(getWrapper(),folder); |
860 | break; | 867 | break; |
861 | case 3: | 868 | case FOLDER_MENU_MOVE_MAILS: |
862 | downloadMails(); | 869 | downloadMails(); |
863 | break; | 870 | break; |
871 | case FOLDER_MENU_REFRESH_HEADER: | ||
872 | view = (AccountView*)listView(); | ||
873 | if (view) view->refreshCurrent(); | ||
874 | break; | ||
864 | default: | 875 | default: |
865 | break; | 876 | break; |
866 | } | 877 | } |
867 | } | 878 | } |
868 | 879 | ||
869 | MHfolderItem::~MHfolderItem() | 880 | MHfolderItem::~MHfolderItem() |
870 | {} | 881 | {} |
871 | 882 | ||
872 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) | 883 | MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) |
873 | : AccountViewItem(folderInit, parent,after ) | 884 | : AccountViewItem(folderInit, parent,after ) |
874 | { | 885 | { |
875 | mbox = parent; | 886 | mbox = parent; |
@@ -947,28 +958,29 @@ void MHfolderItem::deleteFolder() | |||
947 | { | 958 | { |
948 | v->setSelected(box,true); | 959 | v->setSelected(box,true); |
949 | } | 960 | } |
950 | } | 961 | } |
951 | } | 962 | } |
952 | } | 963 | } |
953 | 964 | ||
954 | QPopupMenu * MHfolderItem::getContextMenu() | 965 | QPopupMenu * MHfolderItem::getContextMenu() |
955 | { | 966 | { |
956 | QPopupMenu *m = new QPopupMenu(0); | 967 | QPopupMenu *m = new QPopupMenu(0); |
957 | if (m) | 968 | if (m) |
958 | { | 969 | { |
959 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 970 | m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); |
960 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | 971 | m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); |
961 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); | 972 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); |
962 | m->insertItem(QObject::tr("Delete folder",contextName),1); | 973 | m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); |
974 | m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER); | ||
963 | } | 975 | } |
964 | return m; | 976 | return m; |
965 | } | 977 | } |
966 | 978 | ||
967 | void MHfolderItem::downloadMails() | 979 | void MHfolderItem::downloadMails() |
968 | { | 980 | { |
969 | AccountView*bl = mbox->accountView(); | 981 | AccountView*bl = mbox->accountView(); |
970 | if (!bl) return; | 982 | if (!bl) return; |
971 | bl->downloadMails(folder,mbox->getWrapper()); | 983 | bl->downloadMails(folder,mbox->getWrapper()); |
972 | } | 984 | } |
973 | 985 | ||
974 | void MHfolderItem::createFolder() | 986 | void MHfolderItem::createFolder() |
@@ -985,38 +997,43 @@ void MHfolderItem::createFolder() | |||
985 | * any member of it after that call!!*/ | 997 | * any member of it after that call!!*/ |
986 | mbox->refresh(true); | 998 | mbox->refresh(true); |
987 | if (v) | 999 | if (v) |
988 | { | 1000 | { |
989 | v->setSelected(box,true); | 1001 | v->setSelected(box,true); |
990 | } | 1002 | } |
991 | } | 1003 | } |
992 | } | 1004 | } |
993 | } | 1005 | } |
994 | 1006 | ||
995 | void MHfolderItem::contextMenuSelected(int which) | 1007 | void MHfolderItem::contextMenuSelected(int which) |
996 | { | 1008 | { |
1009 | AccountView*view = 0; | ||
997 | switch(which) | 1010 | switch(which) |
998 | { | 1011 | { |
999 | case 0: | 1012 | case FOLDER_MENU_DELETE_ALL_MAILS: |
1000 | deleteAllMail(mbox->getWrapper(),folder); | 1013 | deleteAllMail(mbox->getWrapper(),folder); |
1001 | break; | 1014 | break; |
1002 | case 1: | 1015 | case FOLDER_MENU_DELETE_FOLDER: |
1003 | deleteFolder(); | 1016 | deleteFolder(); |
1004 | break; | 1017 | break; |
1005 | case 2: | 1018 | case FOLDER_MENU_MOVE_MAILS: |
1006 | downloadMails(); | 1019 | downloadMails(); |
1007 | break; | 1020 | break; |
1008 | case 3: | 1021 | case FOLDER_MENU_NEW_SUBFOLDER: |
1009 | createFolder(); | 1022 | createFolder(); |
1010 | break; | 1023 | break; |
1024 | case FOLDER_MENU_REFRESH_HEADER: | ||
1025 | view = (AccountView*)listView(); | ||
1026 | if (view) view->refreshCurrent(); | ||
1027 | break; | ||
1011 | default: | 1028 | default: |
1012 | break; | 1029 | break; |
1013 | } | 1030 | } |
1014 | } | 1031 | } |
1015 | 1032 | ||
1016 | bool MHfolderItem::isDraftfolder() | 1033 | bool MHfolderItem::isDraftfolder() |
1017 | { | 1034 | { |
1018 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; | 1035 | if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; |
1019 | return false; | 1036 | return false; |
1020 | } | 1037 | } |
1021 | 1038 | ||
1022 | /** | 1039 | /** |