summaryrefslogtreecommitdiffabout
path: root/kmicromail/editaccounts.cpp
Unidiff
Diffstat (limited to 'kmicromail/editaccounts.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/editaccounts.cpp70
1 files changed, 55 insertions, 15 deletions
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp
index d43d23b..733e38a 100644
--- a/kmicromail/editaccounts.cpp
+++ b/kmicromail/editaccounts.cpp
@@ -349,273 +349,313 @@ void IMAPconfig::slotConnectionToggle( int index )
349 else 349 else
350 { 350 {
351 portLine->setText( IMAP_PORT ); 351 portLine->setText( IMAP_PORT );
352 } 352 }
353} 353}
354 354
355void IMAPconfig::fillValues() 355void IMAPconfig::fillValues()
356{ 356{
357 accountLine->setText( data->getAccountName() ); 357 accountLine->setText( data->getAccountName() );
358 serverLine->setText( data->getServer() ); 358 serverLine->setText( data->getServer() );
359 portLine->setText( data->getPort() ); 359 portLine->setText( data->getPort() );
360 ComboBox1->setCurrentItem( data->ConnectionType() ); 360 ComboBox1->setCurrentItem( data->ConnectionType() );
361 userLine->setText( data->getUser() ); 361 userLine->setText( data->getUser() );
362 passLine->setText( data->getPassword() ); 362 passLine->setText( data->getPassword() );
363 prefixLine->setText(data->getPrefix()); 363 prefixLine->setText(data->getPrefix());
364 localFolder->setText( data->getLocalFolder() ); 364 localFolder->setText( data->getLocalFolder() );
365 int max = data->getMaxMailSize() ; 365 int max = data->getMaxMailSize() ;
366 if ( max ) { 366 if ( max ) {
367 CheckBoxDown->setChecked( true ); 367 CheckBoxDown->setChecked( true );
368 SpinBoxDown->setValue ( max ); 368 SpinBoxDown->setValue ( max );
369 } else { 369 } else {
370 CheckBoxDown->setChecked( false ); 370 CheckBoxDown->setChecked( false );
371 SpinBoxDown->setValue ( 5 ); 371 SpinBoxDown->setValue ( 5 );
372 } 372 }
373 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); 373 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() );
374} 374}
375 375
376void IMAPconfig::accept() 376void IMAPconfig::accept()
377{ 377{
378 data->setAccountName( accountLine->text() ); 378 data->setAccountName( accountLine->text() );
379 data->setServer( serverLine->text() ); 379 data->setServer( serverLine->text() );
380 data->setPort( portLine->text() ); 380 data->setPort( portLine->text() );
381 data->setConnectionType( ComboBox1->currentItem() ); 381 data->setConnectionType( ComboBox1->currentItem() );
382 data->setUser( userLine->text() ); 382 data->setUser( userLine->text() );
383 data->setPassword( passLine->text() ); 383 data->setPassword( passLine->text() );
384 data->setPrefix(prefixLine->text()); 384 data->setPrefix(prefixLine->text());
385 data->setLocalFolder( localFolder->text() ); 385 data->setLocalFolder( localFolder->text() );
386 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; 386 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ;
387 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); 387 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() );
388 388
389 QDialog::accept(); 389 QDialog::accept();
390} 390}
391 391
392/** 392/**
393 * POP3config 393 * POP3config
394 */ 394 */
395 395
396POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 396POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
397 : POP3configUI( parent, name, modal, flags ) 397 : POP3configUI( parent, name, modal, flags )
398{ 398{
399 data = account; 399 data = account;
400 fillValues(); 400 fillValues();
401 401
402 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 402 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
403 ComboBox1->insertItem( "Only if available", 0 ); 403 ComboBox1->insertItem( "Only if available", 0 );
404 ComboBox1->insertItem( "Always, Negotiated", 1 ); 404 ComboBox1->insertItem( "Always, Negotiated", 1 );
405 ComboBox1->insertItem( "Connect on secure port", 2 ); 405 ComboBox1->insertItem( "Connect on secure port", 2 );
406 ComboBox1->insertItem( "Run command instead", 3 ); 406 ComboBox1->insertItem( "Run command instead", 3 );
407 CommandEdit->hide(); 407 CommandEdit->hide();
408 ComboBox1->setCurrentItem( data->ConnectionType() ); 408 ComboBox1->setCurrentItem( data->ConnectionType() );
409} 409}
410 410
411void POP3config::slotConnectionToggle( int index ) 411void POP3config::slotConnectionToggle( int index )
412{ 412{
413 // 2 is ssl connection 413 // 2 is ssl connection
414 if ( index == 2 ) 414 if ( index == 2 )
415 { 415 {
416 portLine->setText( POP3_SSL_PORT ); 416 portLine->setText( POP3_SSL_PORT );
417 } 417 }
418 else if ( index == 3 ) 418 else if ( index == 3 )
419 { 419 {
420 portLine->setText( POP3_PORT ); 420 portLine->setText( POP3_PORT );
421 CommandEdit->show(); 421 CommandEdit->show();
422 } 422 }
423 else 423 else
424 { 424 {
425 portLine->setText( POP3_PORT ); 425 portLine->setText( POP3_PORT );
426 } 426 }
427} 427}
428 428
429void POP3config::fillValues() 429void POP3config::fillValues()
430{ 430{
431 accountLine->setText( data->getAccountName() ); 431 accountLine->setText( data->getAccountName() );
432 serverLine->setText( data->getServer() ); 432 serverLine->setText( data->getServer() );
433 portLine->setText( data->getPort() ); 433 portLine->setText( data->getPort() );
434 ComboBox1->setCurrentItem( data->ConnectionType() ); 434 ComboBox1->setCurrentItem( data->ConnectionType() );
435 userLine->setText( data->getUser() ); 435 userLine->setText( data->getUser() );
436 passLine->setText( data->getPassword() ); 436 passLine->setText( data->getPassword() );
437 localFolder->setText( data->getLocalFolder() ); 437 localFolder->setText( data->getLocalFolder() );
438 int max = data->getMaxMailSize() ; 438 int max = data->getMaxMailSize() ;
439 if ( max ) { 439 if ( max ) {
440 CheckBoxDown->setChecked( true ); 440 CheckBoxDown->setChecked( true );
441 SpinBoxDown->setValue ( max ); 441 SpinBoxDown->setValue ( max );
442 } else { 442 } else {
443 CheckBoxDown->setChecked( false ); 443 CheckBoxDown->setChecked( false );
444 SpinBoxDown->setValue ( 5 ); 444 SpinBoxDown->setValue ( 5 );
445 } 445 }
446 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); 446 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() );
447} 447}
448 448
449void POP3config::accept() 449void POP3config::accept()
450{ 450{
451 data->setAccountName( accountLine->text() ); 451 data->setAccountName( accountLine->text() );
452 data->setServer( serverLine->text() ); 452 data->setServer( serverLine->text() );
453 data->setPort( portLine->text() ); 453 data->setPort( portLine->text() );
454 data->setConnectionType( ComboBox1->currentItem() ); 454 data->setConnectionType( ComboBox1->currentItem() );
455 data->setUser( userLine->text() ); 455 data->setUser( userLine->text() );
456 data->setPassword( passLine->text() ); 456 data->setPassword( passLine->text() );
457 data->setLocalFolder( localFolder->text() ); 457 data->setLocalFolder( localFolder->text() );
458 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; 458 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ;
459 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); 459 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() );
460 460
461 QDialog::accept(); 461 QDialog::accept();
462} 462}
463 463
464/** 464/**
465 * SMTPconfig 465 * SMTPconfig
466 */ 466 */
467 467
468SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 468SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
469 : SMTPconfigUI( parent, name, modal, flags ) 469 : SMTPconfigUI( parent, name, modal, flags )
470{ 470{
471 data = account; 471 data = account;
472 472
473 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 473 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
474 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 474 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
475 475
476 fillValues(); 476 fillValues();
477 477
478 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 478 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
479 ComboBox1->insertItem( "Only if available", 0 ); 479 ComboBox1->insertItem( "Only if available", 0 );
480 ComboBox1->insertItem( "Always, Negotiated", 1 ); 480 ComboBox1->insertItem( "Always, Negotiated", 1 );
481 ComboBox1->insertItem( "Connect on secure port", 2 ); 481 ComboBox1->insertItem( "Connect on secure port", 2 );
482 ComboBox1->insertItem( "Run command instead", 3 ); 482 ComboBox1->insertItem( "Run command instead", 3 );
483 CommandEdit->hide(); 483 CommandEdit->hide();
484 ComboBox1->setCurrentItem( data->ConnectionType() ); 484 ComboBox1->setCurrentItem( data->ConnectionType() );
485} 485}
486 486
487void SMTPconfig::slotConnectionToggle( int index ) 487void SMTPconfig::slotConnectionToggle( int index )
488{ 488{
489 // 2 is ssl connection 489 // 2 is ssl connection
490 if ( index == 2 ) 490 if ( index == 2 )
491 { 491 {
492 portLine->setText( SMTP_SSL_PORT ); 492 portLine->setText( SMTP_SSL_PORT );
493 } 493 }
494 else if ( index == 3 ) 494 else if ( index == 3 )
495 { 495 {
496 portLine->setText( SMTP_PORT ); 496 portLine->setText( SMTP_PORT );
497 CommandEdit->show(); 497 CommandEdit->show();
498 } 498 }
499 else 499 else
500 { 500 {
501 portLine->setText( SMTP_PORT ); 501 portLine->setText( SMTP_PORT );
502 } 502 }
503} 503}
504 504
505void SMTPconfig::fillValues() 505void SMTPconfig::fillValues()
506{ 506{
507 accountLine->setText( data->getAccountName() ); 507 accountLine->setText( data->getAccountName() );
508 serverLine->setText( data->getServer() ); 508 serverLine->setText( data->getServer() );
509 portLine->setText( data->getPort() ); 509 portLine->setText( data->getPort() );
510 ComboBox1->setCurrentItem( data->ConnectionType() ); 510 ComboBox1->setCurrentItem( data->ConnectionType() );
511 loginBox->setChecked( data->getLogin() ); 511 loginBox->setChecked( data->getLogin() );
512 userLine->setText( data->getUser() ); 512 userLine->setText( data->getUser() );
513 passLine->setText( data->getPassword() ); 513 passLine->setText( data->getPassword() );
514} 514}
515 515
516void SMTPconfig::accept() 516void SMTPconfig::accept()
517{ 517{
518 data->setAccountName( accountLine->text() ); 518 data->setAccountName( accountLine->text() );
519 data->setServer( serverLine->text() ); 519 data->setServer( serverLine->text() );
520 data->setPort( portLine->text() ); 520 data->setPort( portLine->text() );
521 data->setConnectionType( ComboBox1->currentItem() ); 521 data->setConnectionType( ComboBox1->currentItem() );
522 data->setLogin( loginBox->isChecked() ); 522 data->setLogin( loginBox->isChecked() );
523 data->setUser( userLine->text() ); 523 data->setUser( userLine->text() );
524 data->setPassword( passLine->text() ); 524 data->setPassword( passLine->text() );
525 525
526 QDialog::accept(); 526 QDialog::accept();
527} 527}
528 528
529/** 529/**
530 * NNTPconfig 530 * NNTPconfig
531 */ 531 */
532 532
533NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 533NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
534 : NNTPconfigUI( parent, name, modal, flags ) 534 : NNTPconfigUI( parent, name, modal, flags )
535{ 535{
536 data = account; 536 data = account;
537 537
538 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 538 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
539 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 539 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
540 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); 540 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) );
541 connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) );
542 connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) );
541 fillValues(); 543 fillValues();
542 544
543 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); 545 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) );
544} 546}
545 547
548void NNTPconfig::slotShowSub()
549{
550 save();
551 data->save();
552 ListViewGroups->clear();
553 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
554 QCheckListItem *item;
555 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
556 item->setOn( true );
557 }
558 topLevelWidget()->setCaption( tr("%1 groups subscribed").arg( subscribedGroups.count()));
559}
560void NNTPconfig::slotShowFilter()
561{
562 save();
563 data->save();
564 ListViewGroups->clear();
565 int count = 0;
566 for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) {
567 QCheckListItem *item;
568 if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) {
569 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
570 ++count;
571 if ( subscribedGroups.contains( (*it) ) >= 1 ) {
572 item->setOn( true );
573 }
574 }
575 }
576 topLevelWidget()->setCaption( tr("Filter found %1 groups").arg( count));
577}
546void NNTPconfig::slotGetNG() { 578void NNTPconfig::slotGetNG() {
547 save(); 579 save();
548 data->save(); 580 data->save();
581 topLevelWidget()->setCaption( tr("Fetching group list..."));
582 qApp->processEvents();
549 NNTPwrapper* tmp = new NNTPwrapper( data ); 583 NNTPwrapper* tmp = new NNTPwrapper( data );
550 QStringList list = tmp->listAllNewsgroups(); 584 allGroups = tmp->listAllNewsgroups();
585 topLevelWidget()->setCaption( tr("Downloaded %1 group names").arg( allGroups.count()));
551 586
552 ListViewGroups->clear(); 587 ListViewGroups->clear();
553 588
554 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 589 for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) {
555 QCheckListItem *item; 590 QCheckListItem *item;
556 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 591 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
557 if ( subscribedGroups.contains( (*it) ) >= 1 ) { 592 if ( subscribedGroups.contains( (*it) ) >= 1 ) {
558 item->setOn( true ); 593 item->setOn( true );
559 } 594
595 }
560 } 596 }
597 delete tmp;
561} 598}
562 599
563void NNTPconfig::slotSSL( bool enabled ) 600void NNTPconfig::slotSSL( bool enabled )
564{ 601{
565 if ( enabled ) 602 if ( enabled )
566 { 603 {
567 portLine->setText( NNTP_SSL_PORT ); 604 portLine->setText( NNTP_SSL_PORT );
568 } 605 }
569 else 606 else
570 { 607 {
571 portLine->setText( NNTP_PORT ); 608 portLine->setText( NNTP_PORT );
572 } 609 }
573} 610}
574 611
575void NNTPconfig::fillValues() 612void NNTPconfig::fillValues()
576{ 613{
577 accountLine->setText( data->getAccountName() ); 614 accountLine->setText( data->getAccountName() );
578 serverLine->setText( data->getServer() ); 615 serverLine->setText( data->getServer() );
579 portLine->setText( data->getPort() ); 616 portLine->setText( data->getPort() );
580 sslBox->setChecked( data->getSSL() ); 617 sslBox->setChecked( data->getSSL() );
581 loginBox->setChecked( data->getLogin() ); 618 loginBox->setChecked( data->getLogin() );
582 userLine->setText( data->getUser() ); 619 userLine->setText( data->getUser() );
583 passLine->setText( data->getPassword() ); 620 passLine->setText( data->getPassword() );
584 subscribedGroups = data->getGroups(); 621 subscribedGroups = data->getGroups();
585 /* don't forget that - you will overwrite values if user clicks cancel! */ 622 /* don't forget that - you will overwrite values if user clicks cancel! */
586 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { 623 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
587 QCheckListItem *item; 624 QCheckListItem *item;
588 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 625 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
589 item->setOn( true ); 626 item->setOn( true );
590 } 627 }
591} 628}
592 629
593void NNTPconfig::save() 630void NNTPconfig::save()
594{ 631{
595 data->setAccountName( accountLine->text() ); 632 data->setAccountName( accountLine->text() );
596 data->setServer( serverLine->text() ); 633 data->setServer( serverLine->text() );
597 data->setPort( portLine->text() ); 634 data->setPort( portLine->text() );
598 data->setSSL( sslBox->isChecked() ); 635 data->setSSL( sslBox->isChecked() );
599 data->setLogin( loginBox->isChecked() ); 636 data->setLogin( loginBox->isChecked() );
600 data->setUser( userLine->text() ); 637 data->setUser( userLine->text() );
601 data->setPassword( passLine->text() ); 638 data->setPassword( passLine->text() );
602 639
603 QListViewItemIterator list_it( ListViewGroups ); 640 QListViewItemIterator list_it( ListViewGroups );
604 641
605 QStringList groupList; 642 for ( ; list_it.current(); ++list_it ) {
606 for ( ; list_it.current(); ++list_it ) {
607 643
608 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { 644 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) {
609 groupList.append( list_it.current()->text(0) ); 645 if ( subscribedGroups.contains( list_it.current()->text(0) ) < 1 )
610 } 646 subscribedGroups.append( list_it.current()->text(0) );
647 } else {
648 if ( subscribedGroups.contains( list_it.current()->text(0) ) >= 1 )
649 subscribedGroups.remove( list_it.current()->text(0) );
650 }
611 651
612 } 652 }
613 data->setGroups( groupList ); 653 data->setGroups( subscribedGroups );
614} 654}
615 655
616void NNTPconfig::accept() 656void NNTPconfig::accept()
617{ 657{
618 save(); 658 save();
619 QDialog::accept(); 659 QDialog::accept();
620} 660}
621 661