From b44edfb21be0eee91c4f47401e3fe6ff37e4c16c Mon Sep 17 00:00:00 2001 From: zautrix Date: Thu, 16 Sep 2004 20:39:34 +0000 Subject: better newsgroup handling --- (limited to 'kmicromail/editaccounts.cpp') diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp index d43d23b..733e38a 100644 --- a/kmicromail/editaccounts.cpp +++ b/kmicromail/editaccounts.cpp @@ -538,26 +538,63 @@ 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 ) @@ -600,17 +637,20 @@ void NNTPconfig::save() 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() -- cgit v0.9.0.2