summaryrefslogtreecommitdiffabout
path: root/kmicromail/editaccounts.cpp
authorzautrix <zautrix>2004-09-16 20:39:34 (UTC)
committer zautrix <zautrix>2004-09-16 20:39:34 (UTC)
commitb44edfb21be0eee91c4f47401e3fe6ff37e4c16c (patch) (unidiff)
treea17655e0e679f67498d9fee6f6a532e9c0f0e9e5 /kmicromail/editaccounts.cpp
parentb6bfa63deb15a2600d46a8c68c231f068da1444a (diff)
downloadkdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.zip
kdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.tar.gz
kdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.tar.bz2
better newsgroup handling
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
@@ -517,105 +517,145 @@ void 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