author | zautrix <zautrix> | 2004-09-16 20:39:34 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-16 20:39:34 (UTC) |
commit | b44edfb21be0eee91c4f47401e3fe6ff37e4c16c (patch) (side-by-side diff) | |
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 @@ -525,52 +525,89 @@ void SMTPconfig::accept() QDialog::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 ) { - 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 ) { if ( enabled ) { portLine->setText( NNTP_SSL_PORT ); } else { portLine->setText( NNTP_PORT ); } } void NNTPconfig::fillValues() { @@ -587,35 +624,38 @@ void NNTPconfig::fillValues() QCheckListItem *item; item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); item->setOn( true ); } } 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 ); + 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() { save(); QDialog::accept(); } |