-rw-r--r-- | kmicromail/editaccounts.cpp | 50 |
1 files changed, 45 insertions, 5 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() /** * NNTPconfig */ NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) : NNTPconfigUI( parent, name, modal, flags ) { data = account; 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 ) { + 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 ) { if ( enabled ) { portLine->setText( NNTP_SSL_PORT ); } else { portLine->setText( NNTP_PORT ); } @@ -593,29 +630,32 @@ void NNTPconfig::fillValues() void NNTPconfig::save() { data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); data->setSSL( sslBox->isChecked() ); data->setLogin( loginBox->isChecked() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); QListViewItemIterator list_it( ListViewGroups ); - QStringList groupList; for ( ; list_it.current(); ++list_it ) { if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { - groupList.append( list_it.current()->text(0) ); + 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() { save(); QDialog::accept(); } |