author | zautrix <zautrix> | 2004-09-16 20:39:34 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-16 20:39:34 (UTC) |
commit | b44edfb21be0eee91c4f47401e3fe6ff37e4c16c (patch) (unidiff) | |
tree | a17655e0e679f67498d9fee6f6a532e9c0f0e9e5 /kmicromail/editaccounts.cpp | |
parent | b6bfa63deb15a2600d46a8c68c231f068da1444a (diff) | |
download | kdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.zip kdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.tar.gz kdepimpi-b44edfb21be0eee91c4f47401e3fe6ff37e4c16c.tar.bz2 |
better newsgroup handling
-rw-r--r-- | kmicromail/editaccounts.cpp | 70 |
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 | |||
@@ -529,44 +529,81 @@ void SMTPconfig::accept() | |||
529 | /** | 529 | /** |
530 | * NNTPconfig | 530 | * NNTPconfig |
531 | */ | 531 | */ |
532 | 532 | ||
533 | NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) | 533 | NNTPconfig::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 | ||
548 | void 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 | } | ||
560 | void 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 | } | ||
546 | void NNTPconfig::slotGetNG() { | 578 | void 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 | ||
563 | void NNTPconfig::slotSSL( bool enabled ) | 600 | void 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 | } |
@@ -591,31 +628,34 @@ void NNTPconfig::fillValues() | |||
591 | } | 628 | } |
592 | 629 | ||
593 | void NNTPconfig::save() | 630 | void 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 | ||
616 | void NNTPconfig::accept() | 656 | void NNTPconfig::accept() |
617 | { | 657 | { |
618 | save(); | 658 | save(); |
619 | QDialog::accept(); | 659 | QDialog::accept(); |
620 | } | 660 | } |
621 | 661 | ||