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
@@ -533,36 +533,73 @@ void SMTPconfig::accept()
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 }
@@ -595,27 +632,30 @@ void NNTPconfig::save()
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