summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-12 02:17:39 (UTC)
committer alwin <alwin>2005-03-12 02:17:39 (UTC)
commit4c3ce64f6816353f5b8bc268c126d7c53d18ce46 (patch) (unidiff)
tree1489d76901c287b527ac8fc78b5bbb1179d7110d
parentc30ae1086dfe8bebe1790161ba7df6c5472ded9f (diff)
downloadopie-4c3ce64f6816353f5b8bc268c126d7c53d18ce46.zip
opie-4c3ce64f6816353f5b8bc268c126d7c53d18ce46.tar.gz
opie-4c3ce64f6816353f5b8bc268c126d7c53d18ce46.tar.bz2
pixmaps
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountitem.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
index 4869df8..10db2c6 100644
--- a/noncore/net/mail/accountitem.cpp
+++ b/noncore/net/mail/accountitem.cpp
@@ -150,1003 +150,1003 @@ POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent ,
150 setPixmap( 0, PIXMAP_POP3FOLDER ); 150 setPixmap( 0, PIXMAP_POP3FOLDER );
151 } 151 }
152 else 152 else
153 { 153 {
154 setPixmap( 0, PIXMAP_INBOXFOLDER); 154 setPixmap( 0, PIXMAP_INBOXFOLDER);
155 } 155 }
156 setText( 0, folder->getDisplayName() ); 156 setText( 0, folder->getDisplayName() );
157} 157}
158 158
159void POP3folderItem::refresh(QValueList<RecMailP>&target) 159void POP3folderItem::refresh(QValueList<RecMailP>&target)
160{ 160{
161 if (folder->may_select()) 161 if (folder->may_select())
162 pop3->getWrapper()->listMessages( folder->getName(),target ); 162 pop3->getWrapper()->listMessages( folder->getName(),target );
163} 163}
164 164
165RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail) 165RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail)
166{ 166{
167 return pop3->getWrapper()->fetchBody(aMail); 167 return pop3->getWrapper()->fetchBody(aMail);
168} 168}
169 169
170QPopupMenu * POP3folderItem::getContextMenu() 170QPopupMenu * 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),FOLDER_MENU_REFRESH_HEADER); 175 m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER);
176 m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); 176 m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS);
177 m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); 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
182void POP3folderItem::downloadMails() 182void 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
189void POP3folderItem::contextMenuSelected(int which) 189void 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 FOLDER_MENU_REFRESH_HEADER: 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 FOLDER_MENU_DELETE_ALL_MAILS: 199 case FOLDER_MENU_DELETE_ALL_MAILS:
200 deleteAllMail(pop3->getWrapper(),folder); 200 deleteAllMail(pop3->getWrapper(),folder);
201 break; 201 break;
202 case FOLDER_MENU_MOVE_MAILS: 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 */
213NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) 213NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent )
214 : AccountViewItem( parent ) 214 : AccountViewItem( parent )
215{ 215{
216 account = a; 216 account = a;
217 wrapper = AbstractMail::getWrapper( account ); 217 wrapper = AbstractMail::getWrapper( account );
218 //FIXME 218 //FIXME
219 SETPIX(PIXMAP_POP3FOLDER); 219 SETPIX(PIXMAP_POP3FOLDER);
220#if 0 220#if 0
221 if (!account->getOffline()) 221 if (!account->getOffline())
222 { 222 {
223 setPixmap( 0, ); 223 setPixmap( 0, );
224 } 224 }
225 else 225 else
226 { 226 {
227 setPixmap( 0, PIXMAP_OFFLINE ); 227 setPixmap( 0, PIXMAP_OFFLINE );
228 } 228 }
229#endif 229#endif
230 setText( 0, account->getAccountName() ); 230 setText( 0, account->getAccountName() );
231 setOpen( true ); 231 setOpen( true );
232} 232}
233 233
234NNTPviewItem::~NNTPviewItem() 234NNTPviewItem::~NNTPviewItem()
235{ 235{
236 delete wrapper; 236 delete wrapper;
237} 237}
238 238
239AbstractMail *NNTPviewItem::getWrapper() 239AbstractMail *NNTPviewItem::getWrapper()
240{ 240{
241 return wrapper; 241 return wrapper;
242} 242}
243 243
244void NNTPviewItem::refresh( QValueList<RecMailP> & ) 244void NNTPviewItem::refresh( QValueList<RecMailP> & )
245{ 245{
246 refresh(); 246 refresh();
247} 247}
248 248
249void NNTPviewItem::refresh() 249void NNTPviewItem::refresh()
250{ 250{
251 if (account->getOffline()) return; 251 if (account->getOffline()) return;
252 QValueList<FolderP> *folders = wrapper->listFolders(); 252 QValueList<FolderP> *folders = wrapper->listFolders();
253 253
254 QListViewItem *child = firstChild(); 254 QListViewItem *child = firstChild();
255 while ( child ) 255 while ( child )
256 { 256 {
257 QListViewItem *tmp = child; 257 QListViewItem *tmp = child;
258 child = child->nextSibling(); 258 child = child->nextSibling();
259 delete tmp; 259 delete tmp;
260 } 260 }
261 QValueList<FolderP>::ConstIterator it; 261 QValueList<FolderP>::ConstIterator it;
262 QListViewItem*item = 0; 262 QListViewItem*item = 0;
263 for ( it = folders->begin(); it!=folders->end(); ++it) 263 for ( it = folders->begin(); it!=folders->end(); ++it)
264 { 264 {
265 item = new NNTPfolderItem( (*it), this , item ); 265 item = new NNTPfolderItem( (*it), this , item );
266 item->setSelectable( (*it)->may_select()); 266 item->setSelectable( (*it)->may_select());
267 } 267 }
268 delete folders; 268 delete folders;
269} 269}
270 270
271RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail ) 271RECBODYP 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
277QPopupMenu * NNTPviewItem::getContextMenu() 277QPopupMenu * 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),SERVER_MENU_DISCONNECT); 284 m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT);
285 m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); 285 m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE);
286 m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),SERVER_MENU_SUBSCRIBE); 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),SERVER_MENU_OFFLINE); 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
296void NNTPviewItem::subscribeGroups() 296void 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}
303 303
304void NNTPviewItem::disconnect() 304void NNTPviewItem::disconnect()
305{ 305{
306 QListViewItem *child = firstChild(); 306 QListViewItem *child = firstChild();
307 while ( child ) 307 while ( child )
308 { 308 {
309 QListViewItem *tmp = child; 309 QListViewItem *tmp = child;
310 child = child->nextSibling(); 310 child = child->nextSibling();
311 delete tmp; 311 delete tmp;
312 } 312 }
313 wrapper->logout(); 313 wrapper->logout();
314} 314}
315 315
316void NNTPviewItem::setOnOffline() 316void NNTPviewItem::setOnOffline()
317{ 317{
318 if (!account->getOffline()) 318 if (!account->getOffline())
319 { 319 {
320 disconnect(); 320 disconnect();
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
329void NNTPviewItem::contextMenuSelected(int which) 329void NNTPviewItem::contextMenuSelected(int which)
330{ 330{
331 switch (which) 331 switch (which)
332 { 332 {
333 case SERVER_MENU_DISCONNECT: 333 case SERVER_MENU_DISCONNECT:
334 disconnect(); 334 disconnect();
335 break; 335 break;
336 case SERVER_MENU_OFFLINE: 336 case SERVER_MENU_OFFLINE:
337 setOnOffline(); 337 setOnOffline();
338 break; 338 break;
339 case SERVER_MENU_SUBSCRIBE: 339 case SERVER_MENU_SUBSCRIBE:
340 subscribeGroups(); 340 subscribeGroups();
341 break; 341 break;
342 } 342 }
343} 343}
344 344
345NNTPfolderItem::~NNTPfolderItem() 345NNTPfolderItem::~NNTPfolderItem()
346{} 346{}
347 347
348NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent , QListViewItem*after ) 348NNTPfolderItem::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;
352 if (folder->getDisplayName().lower()!="inbox") 352 if (folder->getDisplayName().lower()!="inbox")
353 { 353 {
354 setPixmap( 0, PIXMAP_POP3FOLDER ); 354 setPixmap( 0, PIXMAP_POP3FOLDER );
355 } 355 }
356 else 356 else
357 { 357 {
358 setPixmap( 0, PIXMAP_INBOXFOLDER); 358 setPixmap( 0, PIXMAP_INBOXFOLDER);
359 } 359 }
360 setText( 0, folder->getDisplayName() ); 360 setText( 0, folder->getDisplayName() );
361} 361}
362 362
363void NNTPfolderItem::refresh(QValueList<RecMailP>&target) 363void NNTPfolderItem::refresh(QValueList<RecMailP>&target)
364{ 364{
365 if (folder->may_select()) 365 if (folder->may_select())
366 nntp->getWrapper()->listMessages( folder->getName(),target ); 366 nntp->getWrapper()->listMessages( folder->getName(),target );
367} 367}
368 368
369RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail) 369RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail)
370{ 370{
371 return nntp->getWrapper()->fetchBody(aMail); 371 return nntp->getWrapper()->fetchBody(aMail);
372} 372}
373 373
374QPopupMenu * NNTPfolderItem::getContextMenu() 374QPopupMenu * 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),FOLDER_MENU_REFRESH_HEADER); 379 m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER);
380 m->insertItem(QObject::tr("Copy all postings",contextName),FOLDER_MENU_MOVE_MAILS); 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
385void NNTPfolderItem::downloadMails() 385void 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
392void NNTPfolderItem::contextMenuSelected(int which) 392void 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 FOLDER_MENU_REFRESH_HEADER: 397 case FOLDER_MENU_REFRESH_HEADER:
398 /* must be 'cause nntp 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 FOLDER_MENU_MOVE_MAILS: 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 */
413IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) 413IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
414 : AccountViewItem( parent ) 414 : AccountViewItem( parent )
415{ 415{
416 account = a; 416 account = a;
417 wrapper = AbstractMail::getWrapper( account ); 417 wrapper = AbstractMail::getWrapper( account );
418 SETPIX(PIXMAP_IMAPFOLDER); 418 SETPIX(PIXMAP_IMAPFOLDER);
419 setText( 0, account->getAccountName() ); 419 setText( 0, account->getAccountName() );
420 setOpen( true ); 420 setOpen( true );
421} 421}
422 422
423IMAPviewItem::~IMAPviewItem() 423IMAPviewItem::~IMAPviewItem()
424{ 424{
425 delete wrapper; 425 delete wrapper;
426} 426}
427 427
428AbstractMail *IMAPviewItem::getWrapper() 428AbstractMail *IMAPviewItem::getWrapper()
429{ 429{
430 return wrapper; 430 return wrapper;
431} 431}
432 432
433void IMAPviewItem::refresh(QValueList<RecMailP>&) 433void IMAPviewItem::refresh(QValueList<RecMailP>&)
434{ 434{
435 refreshFolders(false); 435 refreshFolders(false);
436} 436}
437 437
438const QStringList&IMAPviewItem::subFolders() 438const QStringList&IMAPviewItem::subFolders()
439{ 439{
440 return currentFolders; 440 return currentFolders;
441} 441}
442 442
443void IMAPviewItem::refreshFolders(bool force) 443void IMAPviewItem::refreshFolders(bool force)
444{ 444{
445 if (childCount()>0 && force==false) return; 445 if (childCount()>0 && force==false) return;
446 if (account->getOffline()) return; 446 if (account->getOffline()) return;
447 447
448 removeChilds(); 448 removeChilds();
449 currentFolders.clear(); 449 currentFolders.clear();
450 QValueList<FolderP> * folders = wrapper->listFolders(); 450 QValueList<FolderP> * folders = wrapper->listFolders();
451 451
452 QValueList<FolderP>::Iterator it; 452 QValueList<FolderP>::Iterator it;
453 QListViewItem*item = 0; 453 QListViewItem*item = 0;
454 QListViewItem*titem = 0; 454 QListViewItem*titem = 0;
455 QString fname,del,search; 455 QString fname,del,search;
456 int pos; 456 int pos;
457 457
458 for ( it = folders->begin(); it!=folders->end(); ++it) 458 for ( it = folders->begin(); it!=folders->end(); ++it)
459 { 459 {
460 if ((*it)->getDisplayName().lower()=="inbox") 460 if ((*it)->getDisplayName().lower()=="inbox")
461 { 461 {
462 item = new IMAPfolderItem( (*it), this , item ); 462 item = new IMAPfolderItem( (*it), this , item );
463 folders->remove(it); 463 folders->remove(it);
464 odebug << "inbox found" << oendl; 464 odebug << "inbox found" << oendl;
465 break; 465 break;
466 } 466 }
467 } 467 }
468 for ( it = folders->begin(); it!=folders->end(); ++it) 468 for ( it = folders->begin(); it!=folders->end(); ++it)
469 { 469 {
470 fname = (*it)->getDisplayName(); 470 fname = (*it)->getDisplayName();
471 currentFolders.append((*it)->getName()); 471 currentFolders.append((*it)->getName());
472 pos = fname.findRev((*it)->Separator()); 472 pos = fname.findRev((*it)->Separator());
473 if (pos != -1) 473 if (pos != -1)
474 { 474 {
475 fname = fname.left(pos); 475 fname = fname.left(pos);
476 } 476 }
477 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); 477 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname);
478 if (pitem) 478 if (pitem)
479 { 479 {
480 titem = item; 480 titem = item;
481 item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this); 481 item = new IMAPfolderItem( (*it),pitem,pitem->firstChild(),this);
482 /* setup the short name */ 482 /* setup the short name */
483 item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1)); 483 item->setText(0,(*it)->getDisplayName().right((*it)->getDisplayName().length()-pos-1));
484 item = titem; 484 item = titem;
485 } 485 }
486 else 486 else
487 { 487 {
488 item = new IMAPfolderItem( (*it), this , item ); 488 item = new IMAPfolderItem( (*it), this , item );
489 } 489 }
490 } 490 }
491 delete folders; 491 delete folders;
492} 492}
493 493
494QPopupMenu * IMAPviewItem::getContextMenu() 494QPopupMenu * 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("Disconnect",contextName),SERVER_MENU_DISCONNECT); 501 m->insertItem(QObject::tr("Disconnect",contextName),SERVER_MENU_DISCONNECT);
502 m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE); 502 m->insertItem(QObject::tr("Set offline",contextName),SERVER_MENU_OFFLINE);
503 m->insertSeparator(); 503 m->insertSeparator();
504 m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); 504 m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER);
505 m->insertItem(QObject::tr("Create new folder",contextName),SERVER_MENU_CREATE_FOLDER); 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),SERVER_MENU_OFFLINE); 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
515void IMAPviewItem::createNewFolder() 515void 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();
522 QString delemiter = "/"; 522 QString delemiter = "/";
523 IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); 523 IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
524 if (item) 524 if (item)
525 { 525 {
526 delemiter = item->Delemiter(); 526 delemiter = item->Delemiter();
527 } 527 }
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
535void IMAPviewItem::contextMenuSelected(int id) 535void 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 SERVER_MENU_REFRESH_FOLDER: 540 case SERVER_MENU_REFRESH_FOLDER:
541 refreshFolders(true); 541 refreshFolders(true);
542 break; 542 break;
543 case SERVER_MENU_CREATE_FOLDER: 543 case SERVER_MENU_CREATE_FOLDER:
544 createNewFolder(); 544 createNewFolder();
545 break; 545 break;
546 case SERVER_MENU_DISCONNECT: 546 case SERVER_MENU_DISCONNECT:
547 removeChilds(); 547 removeChilds();
548 wrapper->logout(); 548 wrapper->logout();
549 break; 549 break;
550 case SERVER_MENU_OFFLINE: 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;
563 } 563 }
564} 564}
565 565
566RECBODYP IMAPviewItem::fetchBody(const RecMailP&) 566RECBODYP IMAPviewItem::fetchBody(const RecMailP&)
567{ 567{
568 return new RecBody(); 568 return new RecBody();
569} 569}
570 570
571bool IMAPviewItem::offline() 571bool IMAPviewItem::offline()
572{ 572{
573 return account->getOffline(); 573 return account->getOffline();
574} 574}
575 575
576IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after ) 576IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after )
577 : AccountViewItem( folderInit, parent , after ) 577 : AccountViewItem( folderInit, parent , after )
578{ 578{
579 imap = parent; 579 imap = parent;
580 if (folder->getDisplayName().lower()!="inbox") 580 if (folder->getDisplayName().lower()!="inbox")
581 { 581 {
582 setPixmap( 0, PIXMAP_IMAPFOLDER ); 582 setPixmap( 0, PIXMAP_IMAPFOLDER );
583 } 583 }
584 else 584 else
585 { 585 {
586 setPixmap( 0, PIXMAP_INBOXFOLDER); 586 setPixmap( 0, PIXMAP_INBOXFOLDER);
587 } 587 }
588 setText( 0, folder->getDisplayName() ); 588 setText( 0, folder->getDisplayName() );
589} 589}
590 590
591IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 591IMAPfolderItem::IMAPfolderItem(const FolderP &folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
592 : AccountViewItem(folderInit, parent,after ) 592 : AccountViewItem(folderInit, parent,after )
593{ 593{
594 imap = master; 594 imap = master;
595 if (folder->getDisplayName().lower()!="inbox") 595 if (folder->getDisplayName().lower()!="inbox")
596 { 596 {
597 setPixmap( 0, PIXMAP_IMAPFOLDER ); 597 setPixmap( 0, PIXMAP_IMAPFOLDER );
598 } 598 }
599 else 599 else
600 { 600 {
601 setPixmap( 0, PIXMAP_INBOXFOLDER); 601 setPixmap( 0, PIXMAP_INBOXFOLDER);
602 } 602 }
603 setText( 0, folder->getDisplayName() ); 603 setText( 0, folder->getDisplayName() );
604} 604}
605 605
606IMAPfolderItem::~IMAPfolderItem() 606IMAPfolderItem::~IMAPfolderItem()
607{} 607{}
608 608
609const QString& IMAPfolderItem::Delemiter()const 609const QString& IMAPfolderItem::Delemiter()const
610{ 610{
611 return folder->Separator(); 611 return folder->Separator();
612} 612}
613 613
614void IMAPfolderItem::refresh(QValueList<RecMailP>&target) 614void IMAPfolderItem::refresh(QValueList<RecMailP>&target)
615{ 615{
616 if (folder->may_select()) 616 if (folder->may_select())
617 { 617 {
618 imap->getWrapper()->listMessages( folder->getName(),target ); 618 imap->getWrapper()->listMessages( folder->getName(),target );
619 } 619 }
620 else 620 else
621 { 621 {
622 target.clear(); 622 target.clear();
623 } 623 }
624} 624}
625 625
626RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail) 626RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail)
627{ 627{
628 return imap->getWrapper()->fetchBody(aMail); 628 return imap->getWrapper()->fetchBody(aMail);
629} 629}
630 630
631QPopupMenu * IMAPfolderItem::getContextMenu() 631QPopupMenu * 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),FOLDER_MENU_REFRESH_HEADER); 638 m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER);
639 m->insertItem(QObject::tr("Move/Copy all mails",contextName),FOLDER_MENU_MOVE_MAILS); 639 m->insertItem(QObject::tr("Move/Copy all mails",contextName),FOLDER_MENU_MOVE_MAILS);
640 m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); 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),FOLDER_MENU_NEW_SUBFOLDER); 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),FOLDER_MENU_DELETE_FOLDER); 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
654void IMAPfolderItem::createNewFolder() 654void 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();
661 QString delemiter = Delemiter(); 661 QString delemiter = Delemiter();
662 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) 662 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs))
663 { 663 {
664 imap->refreshFolders(true); 664 imap->refreshFolders(true);
665 } 665 }
666 } 666 }
667} 667}
668 668
669void IMAPfolderItem::deleteFolder() 669void IMAPfolderItem::deleteFolder()
670{ 670{
671 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 671 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
672 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 672 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
673 QObject::tr("Yes",contextName), 673 QObject::tr("Yes",contextName),
674 QObject::tr("No",contextName),QString::null,1,1); 674 QObject::tr("No",contextName),QString::null,1,1);
675 odebug << "Auswahl: " << yesno << "" << oendl; 675 odebug << "Auswahl: " << yesno << "" << oendl;
676 if (yesno == 0) 676 if (yesno == 0)
677 { 677 {
678 if (imap->getWrapper()->deleteMbox(folder)) 678 if (imap->getWrapper()->deleteMbox(folder))
679 { 679 {
680 QListView*v=listView(); 680 QListView*v=listView();
681 IMAPviewItem * box = imap; 681 IMAPviewItem * box = imap;
682 /* be carefull - after that this object is destroyd so don't use 682 /* be carefull - after that this object is destroyd so don't use
683 * any member of it after that call!!*/ 683 * any member of it after that call!!*/
684 imap->refreshFolders(true); 684 imap->refreshFolders(true);
685 if (v) 685 if (v)
686 { 686 {
687 v->setSelected(box,true); 687 v->setSelected(box,true);
688 } 688 }
689 } 689 }
690 } 690 }
691} 691}
692 692
693void IMAPfolderItem::downloadMails() 693void 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
700void IMAPfolderItem::contextMenuSelected(int id) 700void 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 FOLDER_MENU_REFRESH_HEADER: 706 case FOLDER_MENU_REFRESH_HEADER:
707 view->refreshCurrent(); 707 view->refreshCurrent();
708 break; 708 break;
709 case FOLDER_MENU_DELETE_ALL_MAILS: 709 case FOLDER_MENU_DELETE_ALL_MAILS:
710 deleteAllMail(imap->getWrapper(),folder); 710 deleteAllMail(imap->getWrapper(),folder);
711 break; 711 break;
712 case FOLDER_MENU_NEW_SUBFOLDER: 712 case FOLDER_MENU_NEW_SUBFOLDER:
713 if (folder->no_inferior()==false) { 713 if (folder->no_inferior()==false) {
714 createNewFolder(); 714 createNewFolder();
715 } 715 }
716 break; 716 break;
717 case FOLDER_MENU_DELETE_FOLDER: 717 case FOLDER_MENU_DELETE_FOLDER:
718 if (folder->getDisplayName().lower()!="inbox") { 718 if (folder->getDisplayName().lower()!="inbox") {
719 deleteFolder(); 719 deleteFolder();
720 } 720 }
721 break; 721 break;
722 case FOLDER_MENU_MOVE_MAILS: 722 case FOLDER_MENU_MOVE_MAILS:
723 downloadMails(); 723 downloadMails();
724 break; 724 break;
725 default: 725 default:
726 break; 726 break;
727 } 727 }
728} 728}
729 729
730/** 730/**
731 * MH Account stuff 731 * MH Account stuff
732 */ 732 */
733/* 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
734 POP3 and MBOX */ 734 POP3 and MBOX */
735MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) 735MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
736 : AccountViewItem( parent ) 736 : AccountViewItem( parent )
737{ 737{
738 m_Path = aPath; 738 m_Path = aPath;
739 /* be carefull - the space within settext is wanted - thats why the string twice */ 739 /* be carefull - the space within settext is wanted - thats why the string twice */
740 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); 740 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders");
741 setPixmap( 0, PIXMAP_LOCALFOLDER ); 741 setPixmap( 0, PIXMAP_LOCALFOLDER );
742 setText( 0, " Local Folders" ); 742 setText( 0, " Local Folders" );
743 setOpen( true ); 743 setOpen( true );
744 folder = 0; 744 folder = 0;
745} 745}
746 746
747MHviewItem::~MHviewItem() 747MHviewItem::~MHviewItem()
748{ 748{
749 delete wrapper; 749 delete wrapper;
750} 750}
751 751
752AbstractMail *MHviewItem::getWrapper() 752AbstractMail *MHviewItem::getWrapper()
753{ 753{
754 return wrapper; 754 return wrapper;
755} 755}
756 756
757void MHviewItem::refresh( QValueList<RecMailP> & target) 757void MHviewItem::refresh( QValueList<RecMailP> & target)
758{ 758{
759 refresh(false); 759 refresh(false);
760 getWrapper()->listMessages( "",target ); 760 getWrapper()->listMessages( "",target );
761} 761}
762 762
763void MHviewItem::refresh(bool force) 763void MHviewItem::refresh(bool force)
764{ 764{
765 if (childCount()>0 && force==false) return; 765 if (childCount()>0 && force==false) return;
766 odebug << "Refresh mh folders" << oendl; 766 odebug << "Refresh mh folders" << oendl;
767 removeChilds(); 767 removeChilds();
768 currentFolders.clear(); 768 currentFolders.clear();
769 QValueList<FolderP> *folders = wrapper->listFolders(); 769 QValueList<FolderP> *folders = wrapper->listFolders();
770 QValueList<FolderP>::ConstIterator it; 770 QValueList<FolderP>::ConstIterator it;
771 MHfolderItem*item = 0; 771 MHfolderItem*item = 0;
772 MHfolderItem*pmaster = 0; 772 MHfolderItem*pmaster = 0;
773 QString fname = ""; 773 QString fname = "";
774 int pos; 774 int pos;
775 for ( it = folders->begin(); it!=folders->end(); ++it) 775 for ( it = folders->begin(); it!=folders->end(); ++it)
776 { 776 {
777 fname = (*it)->getDisplayName(); 777 fname = (*it)->getDisplayName();
778 /* this folder itself */ 778 /* this folder itself */
779 if (fname=="/") 779 if (fname=="/")
780 { 780 {
781 currentFolders.append(fname); 781 currentFolders.append(fname);
782 folder = (*it); 782 folder = (*it);
783 continue; 783 continue;
784 } 784 }
785 currentFolders.append(fname); 785 currentFolders.append(fname);
786 pos = fname.findRev("/"); 786 pos = fname.findRev("/");
787 if (pos > 0) 787 if (pos > 0)
788 { 788 {
789 fname = fname.left(pos); 789 fname = fname.left(pos);
790 pmaster = (MHfolderItem*)findSubItem(fname); 790 pmaster = (MHfolderItem*)findSubItem(fname);
791 } 791 }
792 else 792 else
793 { 793 {
794 pmaster = 0; 794 pmaster = 0;
795 } 795 }
796 if (pmaster) 796 if (pmaster)
797 { 797 {
798 item = new MHfolderItem( (*it), pmaster, item, this ); 798 item = new MHfolderItem( (*it), pmaster, item, this );
799 } 799 }
800 else 800 else
801 { 801 {
802 item = new MHfolderItem( (*it), this , item ); 802 item = new MHfolderItem( (*it), this , item );
803 } 803 }
804 item->setSelectable((*it)->may_select()); 804 item->setSelectable((*it)->may_select());
805 } 805 }
806 delete folders; 806 delete folders;
807} 807}
808 808
809RECBODYP MHviewItem::fetchBody( const RecMailP &mail ) 809RECBODYP MHviewItem::fetchBody( const RecMailP &mail )
810{ 810{
811 odebug << "MH fetchBody" << oendl; 811 odebug << "MH fetchBody" << oendl;
812 return wrapper->fetchBody( mail ); 812 return wrapper->fetchBody( mail );
813} 813}
814 814
815QPopupMenu * MHviewItem::getContextMenu() 815QPopupMenu * MHviewItem::getContextMenu()
816{ 816{
817 QPopupMenu *m = new QPopupMenu(0); 817 QPopupMenu *m = new QPopupMenu(0);
818 if (m) 818 if (m)
819 { 819 {
820 m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER); 820 m->insertItem(QObject::tr("Refresh folder list",contextName),SERVER_MENU_REFRESH_FOLDER);
821 m->insertItem(QObject::tr("Create new folder",contextName),FOLDER_MENU_NEW_SUBFOLDER); 821 m->insertItem(QObject::tr("Create new folder",contextName),FOLDER_MENU_NEW_SUBFOLDER);
822 m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); 822 m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS);
823 m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); 823 m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS);
824 } 824 }
825 return m; 825 return m;
826} 826}
827 827
828void MHviewItem::createFolder() 828void MHviewItem::createFolder()
829{ 829{
830 Newmdirdlg ndirdlg(0,0,true); 830 Newmdirdlg ndirdlg(0,0,true);
831 if ( QPEApplication::execDialog( &ndirdlg ) ) 831 if ( QPEApplication::execDialog( &ndirdlg ) )
832 { 832 {
833 QString ndir = ndirdlg.Newdir(); 833 QString ndir = ndirdlg.Newdir();
834 if (wrapper->createMbox(ndir)) 834 if (wrapper->createMbox(ndir))
835 { 835 {
836 refresh(true); 836 refresh(true);
837 } 837 }
838 } 838 }
839} 839}
840 840
841void MHviewItem::downloadMails() 841void MHviewItem::downloadMails()
842{ 842{
843 AccountView*bl = accountView(); 843 AccountView*bl = accountView();
844 if (!bl) return; 844 if (!bl) return;
845 bl->downloadMails(folder,getWrapper()); 845 bl->downloadMails(folder,getWrapper());
846} 846}
847 847
848QStringList MHviewItem::subFolders() 848QStringList MHviewItem::subFolders()
849{ 849{
850 return currentFolders; 850 return currentFolders;
851} 851}
852 852
853void MHviewItem::contextMenuSelected(int which) 853void MHviewItem::contextMenuSelected(int which)
854{ 854{
855 AccountView*view = 0; 855 AccountView*view = 0;
856 856
857 switch (which) 857 switch (which)
858 { 858 {
859 case SERVER_MENU_REFRESH_FOLDER: 859 case SERVER_MENU_REFRESH_FOLDER:
860 refresh(true); 860 refresh(true);
861 break; 861 break;
862 case FOLDER_MENU_NEW_SUBFOLDER: 862 case FOLDER_MENU_NEW_SUBFOLDER:
863 createFolder(); 863 createFolder();
864 break; 864 break;
865 case FOLDER_MENU_DELETE_ALL_MAILS: 865 case FOLDER_MENU_DELETE_ALL_MAILS:
866 deleteAllMail(getWrapper(),folder); 866 deleteAllMail(getWrapper(),folder);
867 break; 867 break;
868 case FOLDER_MENU_MOVE_MAILS: 868 case FOLDER_MENU_MOVE_MAILS:
869 downloadMails(); 869 downloadMails();
870 break; 870 break;
871 case FOLDER_MENU_REFRESH_HEADER: 871 case FOLDER_MENU_REFRESH_HEADER:
872 view = (AccountView*)listView(); 872 view = (AccountView*)listView();
873 if (view) view->refreshCurrent(); 873 if (view) view->refreshCurrent();
874 break; 874 break;
875 default: 875 default:
876 break; 876 break;
877 } 877 }
878} 878}
879 879
880MHfolderItem::~MHfolderItem() 880MHfolderItem::~MHfolderItem()
881{} 881{}
882 882
883MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) 883MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after )
884 : AccountViewItem(folderInit, parent,after ) 884 : AccountViewItem(folderInit, parent,after )
885{ 885{
886 mbox = parent; 886 mbox = parent;
887 initName(); 887 initName();
888} 888}
889 889
890MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) 890MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master)
891 : AccountViewItem(folderInit, parent,after ) 891 : AccountViewItem(folderInit, parent,after )
892{ 892{
893 folder = folderInit; 893 folder = folderInit;
894 mbox = master; 894 mbox = master;
895 initName(); 895 initName();
896} 896}
897 897
898void MHfolderItem::initName() 898void MHfolderItem::initName()
899{ 899{
900 QString bName = folder->getDisplayName(); 900 QString bName = folder->getDisplayName();
901 if (bName.startsWith("/")&&bName.length()>1) 901 if (bName.startsWith("/")&&bName.length()>1)
902 { 902 {
903 bName.replace(0,1,""); 903 bName.replace(0,1,"");
904 } 904 }
905 int pos = bName.findRev("/"); 905 int pos = bName.findRev("/");
906 if (pos > 0) 906 if (pos > 0)
907 { 907 {
908 bName.replace(0,pos+1,""); 908 bName.replace(0,pos+1,"");
909 } 909 }
910 if (bName.lower() == "outgoing") 910 if (bName.lower() == "outgoing")
911 { 911 {
912 setPixmap( 0, PIXMAP_OUTBOXFOLDER ); 912 setPixmap( 0, PIXMAP_OUTBOXFOLDER );
913 } 913 }
914 else if (bName.lower() == "inbox") 914 else if (bName.lower() == "inbox")
915 { 915 {
916 setPixmap( 0, PIXMAP_INBOXFOLDER); 916 setPixmap( 0, PIXMAP_INBOXFOLDER);
917 } else if (bName.lower() == "drafts") { 917 } else if (bName.lower() == "drafts") {
918 setPixmap(0, Resource::loadPixmap("inline/edit")); 918 setPixmap(0, Resource::loadPixmap("edit"));
919 } else { 919 } else {
920 setPixmap( 0, PIXMAP_MBOXFOLDER ); 920 setPixmap( 0, PIXMAP_MBOXFOLDER );
921 } 921 }
922 setText( 0, bName ); 922 setText( 0, bName );
923} 923}
924 924
925const FolderP&MHfolderItem::getFolder()const 925const FolderP&MHfolderItem::getFolder()const
926{ 926{
927 return folder; 927 return folder;
928} 928}
929 929
930void MHfolderItem::refresh(QValueList<RecMailP>&target) 930void MHfolderItem::refresh(QValueList<RecMailP>&target)
931{ 931{
932 if (folder->may_select()) 932 if (folder->may_select())
933 mbox->getWrapper()->listMessages( folder->getName(),target ); 933 mbox->getWrapper()->listMessages( folder->getName(),target );
934} 934}
935 935
936RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail) 936RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail)
937{ 937{
938 return mbox->getWrapper()->fetchBody(aMail); 938 return mbox->getWrapper()->fetchBody(aMail);
939} 939}
940 940
941void MHfolderItem::deleteFolder() 941void MHfolderItem::deleteFolder()
942{ 942{
943 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 943 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
944 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 944 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
945 QObject::tr("Yes",contextName), 945 QObject::tr("Yes",contextName),
946 QObject::tr("No",contextName),QString::null,1,1); 946 QObject::tr("No",contextName),QString::null,1,1);
947 odebug << "Auswahl: " << yesno << "" << oendl; 947 odebug << "Auswahl: " << yesno << "" << oendl;
948 if (yesno == 0) 948 if (yesno == 0)
949 { 949 {
950 if (mbox->getWrapper()->deleteMbox(folder)) 950 if (mbox->getWrapper()->deleteMbox(folder))
951 { 951 {
952 QListView*v=listView(); 952 QListView*v=listView();
953 MHviewItem * box = mbox; 953 MHviewItem * box = mbox;
954 /* be carefull - after that this object is destroyd so don't use 954 /* be carefull - after that this object is destroyd so don't use
955 * any member of it after that call!!*/ 955 * any member of it after that call!!*/
956 mbox->refresh(true); 956 mbox->refresh(true);
957 if (v) 957 if (v)
958 { 958 {
959 v->setSelected(box,true); 959 v->setSelected(box,true);
960 } 960 }
961 } 961 }
962 } 962 }
963} 963}
964 964
965QPopupMenu * MHfolderItem::getContextMenu() 965QPopupMenu * MHfolderItem::getContextMenu()
966{ 966{
967 QPopupMenu *m = new QPopupMenu(0); 967 QPopupMenu *m = new QPopupMenu(0);
968 if (m) 968 if (m)
969 { 969 {
970 m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER); 970 m->insertItem(QObject::tr("Create new subfolder",contextName),FOLDER_MENU_NEW_SUBFOLDER);
971 m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER); 971 m->insertItem(QObject::tr("Refresh header list",contextName),FOLDER_MENU_REFRESH_HEADER);
972 m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS); 972 m->insertItem(QObject::tr("Move/Copie all mails",contextName),FOLDER_MENU_MOVE_MAILS);
973 m->insertItem(QObject::tr("Delete all mails",contextName),FOLDER_MENU_DELETE_ALL_MAILS); 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); 974 m->insertItem(QObject::tr("Delete folder",contextName),FOLDER_MENU_DELETE_FOLDER);
975 } 975 }
976 return m; 976 return m;
977} 977}
978 978
979void MHfolderItem::downloadMails() 979void MHfolderItem::downloadMails()
980{ 980{
981 AccountView*bl = mbox->accountView(); 981 AccountView*bl = mbox->accountView();
982 if (!bl) return; 982 if (!bl) return;
983 bl->downloadMails(folder,mbox->getWrapper()); 983 bl->downloadMails(folder,mbox->getWrapper());
984} 984}
985 985
986void MHfolderItem::createFolder() 986void MHfolderItem::createFolder()
987{ 987{
988 Newmdirdlg ndirdlg(0,0,true); 988 Newmdirdlg ndirdlg(0,0,true);
989 if ( QPEApplication::execDialog( &ndirdlg ) ) 989 if ( QPEApplication::execDialog( &ndirdlg ) )
990 { 990 {
991 QString ndir = ndirdlg.Newdir(); 991 QString ndir = ndirdlg.Newdir();
992 if (mbox->getWrapper()->createMbox(ndir,folder)) 992 if (mbox->getWrapper()->createMbox(ndir,folder))
993 { 993 {
994 QListView*v=listView(); 994 QListView*v=listView();
995 MHviewItem * box = mbox; 995 MHviewItem * box = mbox;
996 /* be carefull - after that this object is destroyd so don't use 996 /* be carefull - after that this object is destroyd so don't use
997 * any member of it after that call!!*/ 997 * any member of it after that call!!*/
998 mbox->refresh(true); 998 mbox->refresh(true);
999 if (v) 999 if (v)
1000 { 1000 {
1001 v->setSelected(box,true); 1001 v->setSelected(box,true);
1002 } 1002 }
1003 } 1003 }
1004 } 1004 }
1005} 1005}
1006 1006
1007void MHfolderItem::contextMenuSelected(int which) 1007void MHfolderItem::contextMenuSelected(int which)
1008{ 1008{
1009 AccountView*view = 0; 1009 AccountView*view = 0;
1010 switch(which) 1010 switch(which)
1011 { 1011 {
1012 case FOLDER_MENU_DELETE_ALL_MAILS: 1012 case FOLDER_MENU_DELETE_ALL_MAILS:
1013 deleteAllMail(mbox->getWrapper(),folder); 1013 deleteAllMail(mbox->getWrapper(),folder);
1014 break; 1014 break;
1015 case FOLDER_MENU_DELETE_FOLDER: 1015 case FOLDER_MENU_DELETE_FOLDER:
1016 deleteFolder(); 1016 deleteFolder();
1017 break; 1017 break;
1018 case FOLDER_MENU_MOVE_MAILS: 1018 case FOLDER_MENU_MOVE_MAILS:
1019 downloadMails(); 1019 downloadMails();
1020 break; 1020 break;
1021 case FOLDER_MENU_NEW_SUBFOLDER: 1021 case FOLDER_MENU_NEW_SUBFOLDER:
1022 createFolder(); 1022 createFolder();
1023 break; 1023 break;
1024 case FOLDER_MENU_REFRESH_HEADER: 1024 case FOLDER_MENU_REFRESH_HEADER:
1025 view = (AccountView*)listView(); 1025 view = (AccountView*)listView();
1026 if (view) view->refreshCurrent(); 1026 if (view) view->refreshCurrent();
1027 break; 1027 break;
1028 default: 1028 default:
1029 break; 1029 break;
1030 } 1030 }
1031} 1031}
1032 1032
1033bool MHfolderItem::isDraftfolder() 1033bool MHfolderItem::isDraftfolder()
1034{ 1034{
1035 if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; 1035 if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true;
1036 return false; 1036 return false;
1037} 1037}
1038 1038
1039/** 1039/**
1040 * Generic stuff 1040 * Generic stuff
1041 */ 1041 */
1042 1042
1043const QString AccountViewItem::contextName="AccountViewItem"; 1043const QString AccountViewItem::contextName="AccountViewItem";
1044 1044
1045AccountViewItem::AccountViewItem( AccountView *parent ) 1045AccountViewItem::AccountViewItem( AccountView *parent )
1046 : QListViewItem( parent ) 1046 : QListViewItem( parent )
1047{ 1047{
1048 init(); 1048 init();
1049 m_Backlink = parent; 1049 m_Backlink = parent;
1050} 1050}
1051 1051
1052AccountViewItem::AccountViewItem( QListViewItem *parent) 1052AccountViewItem::AccountViewItem( QListViewItem *parent)
1053 : QListViewItem( parent),folder(0) 1053 : QListViewItem( parent),folder(0)
1054{ 1054{
1055 init(); 1055 init();
1056} 1056}
1057 1057
1058AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) 1058AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
1059 :QListViewItem( parent,after ),folder(0) 1059 :QListViewItem( parent,after ),folder(0)
1060{ 1060{
1061 init(); 1061 init();
1062} 1062}
1063 1063
1064AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) 1064AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after )
1065 :QListViewItem( parent,after ),folder(folderInit) 1065 :QListViewItem( parent,after ),folder(folderInit)
1066{ 1066{
1067 init(); 1067 init();
1068} 1068}
1069 1069
1070void AccountViewItem::init() 1070void AccountViewItem::init()
1071{ 1071{
1072 m_Backlink = 0; 1072 m_Backlink = 0;
1073} 1073}
1074 1074
1075AccountViewItem::~AccountViewItem() 1075AccountViewItem::~AccountViewItem()
1076{ 1076{
1077 folder = 0; 1077 folder = 0;
1078} 1078}
1079 1079
1080AccountView*AccountViewItem::accountView() 1080AccountView*AccountViewItem::accountView()
1081{ 1081{
1082 return m_Backlink; 1082 return m_Backlink;
1083} 1083}
1084 1084
1085void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) 1085void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder)
1086{ 1086{
1087 if (!wrapper) return; 1087 if (!wrapper) return;
1088 QString fname=""; 1088 QString fname="";
1089 if (folder) fname = folder->getDisplayName(); 1089 if (folder) fname = folder->getDisplayName();
1090 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), 1090 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
1091 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). 1091 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).
1092 arg(fname), 1092 arg(fname),
1093 QObject::tr("Yes",contextName), 1093 QObject::tr("Yes",contextName),
1094 QObject::tr("No",contextName),QString::null,1,1); 1094 QObject::tr("No",contextName),QString::null,1,1);
1095 odebug << "Auswahl: " << yesno << "" << oendl; 1095 odebug << "Auswahl: " << yesno << "" << oendl;
1096 if (yesno == 0) 1096 if (yesno == 0)
1097 { 1097 {
1098 if (wrapper->deleteAllMail(folder)) 1098 if (wrapper->deleteAllMail(folder))
1099 { 1099 {
1100 AccountView * view = (AccountView*)listView(); 1100 AccountView * view = (AccountView*)listView();
1101 if (view) view->refreshCurrent(); 1101 if (view) view->refreshCurrent();
1102 } 1102 }
1103 } 1103 }
1104} 1104}
1105 1105
1106void AccountViewItem::removeChilds() 1106void AccountViewItem::removeChilds()
1107{ 1107{
1108 QListViewItem *child = firstChild(); 1108 QListViewItem *child = firstChild();
1109 while ( child ) 1109 while ( child )
1110 { 1110 {
1111 QListViewItem *tmp = child; 1111 QListViewItem *tmp = child;
1112 child = child->nextSibling(); 1112 child = child->nextSibling();
1113 delete tmp; 1113 delete tmp;
1114 } 1114 }
1115} 1115}
1116 1116
1117bool AccountViewItem::matchName(const QString&name)const 1117bool AccountViewItem::matchName(const QString&name)const
1118{ 1118{
1119 if (!folder) return false; 1119 if (!folder) return false;
1120 return folder->getDisplayName()==name; 1120 return folder->getDisplayName()==name;
1121} 1121}
1122 1122
1123 1123
1124AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) 1124AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start)
1125{ 1125{
1126 AccountViewItem*pitem,*sitem; 1126 AccountViewItem*pitem,*sitem;
1127 if (!start) pitem = (AccountViewItem*)firstChild(); 1127 if (!start) pitem = (AccountViewItem*)firstChild();
1128 else pitem = (AccountViewItem*)start->firstChild(); 1128 else pitem = (AccountViewItem*)start->firstChild();
1129 while (pitem) 1129 while (pitem)
1130 { 1130 {
1131 if (pitem->matchName(path)) 1131 if (pitem->matchName(path))
1132 { 1132 {
1133 break; 1133 break;
1134 } 1134 }
1135 if (pitem->childCount()>0) 1135 if (pitem->childCount()>0)
1136 { 1136 {
1137 sitem = findSubItem(path,pitem); 1137 sitem = findSubItem(path,pitem);
1138 if (sitem) 1138 if (sitem)
1139 { 1139 {
1140 pitem = sitem; 1140 pitem = sitem;
1141 break; 1141 break;
1142 } 1142 }
1143 } 1143 }
1144 pitem=(AccountViewItem*)pitem->nextSibling(); 1144 pitem=(AccountViewItem*)pitem->nextSibling();
1145 } 1145 }
1146 return pitem; 1146 return pitem;
1147} 1147}
1148 1148
1149bool AccountViewItem::isDraftfolder() 1149bool AccountViewItem::isDraftfolder()
1150{ 1150{
1151 return false; 1151 return false;
1152} 1152}