-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 @@ -537,28 +537,65 @@ NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); + connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) ); + connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) ); fillValues(); connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); } +void NNTPconfig::slotShowSub() +{ + save(); + data->save(); + ListViewGroups->clear(); + for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { + QCheckListItem *item; + item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); + item->setOn( true ); + } + topLevelWidget()->setCaption( tr("%1 groups subscribed").arg( subscribedGroups.count())); +} +void NNTPconfig::slotShowFilter() +{ + save(); + data->save(); + ListViewGroups->clear(); + int count = 0; + for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { + QCheckListItem *item; + if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) { + item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); + ++count; + if ( subscribedGroups.contains( (*it) ) >= 1 ) { + item->setOn( true ); + } + } + } + topLevelWidget()->setCaption( tr("Filter found %1 groups").arg( count)); +} void NNTPconfig::slotGetNG() { save(); data->save(); + topLevelWidget()->setCaption( tr("Fetching group list...")); + qApp->processEvents(); NNTPwrapper* tmp = new NNTPwrapper( data ); - QStringList list = tmp->listAllNewsgroups(); + allGroups = tmp->listAllNewsgroups(); + topLevelWidget()->setCaption( tr("Downloaded %1 group names").arg( allGroups.count())); ListViewGroups->clear(); - for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { - QCheckListItem *item; - item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); - if ( subscribedGroups.contains( (*it) ) >= 1 ) { - item->setOn( true ); - } + for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { + QCheckListItem *item; + item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); + if ( subscribedGroups.contains( (*it) ) >= 1 ) { + item->setOn( true ); + + } } + delete tmp; } void NNTPconfig::slotSSL( bool enabled ) { @@ -599,19 +636,22 @@ void NNTPconfig::save() data->setLogin( loginBox->isChecked() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); - QListViewItemIterator list_it( ListViewGroups ); + QListViewItemIterator list_it( ListViewGroups ); - QStringList groupList; - for ( ; list_it.current(); ++list_it ) { + for ( ; list_it.current(); ++list_it ) { - if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { - groupList.append( list_it.current()->text(0) ); - } + if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { + if ( subscribedGroups.contains( list_it.current()->text(0) ) < 1 ) + subscribedGroups.append( list_it.current()->text(0) ); + } else { + if ( subscribedGroups.contains( list_it.current()->text(0) ) >= 1 ) + subscribedGroups.remove( list_it.current()->text(0) ); + } - } - data->setGroups( groupList ); + } + data->setGroups( subscribedGroups ); } void NNTPconfig::accept() { |