summaryrefslogtreecommitdiffabout
path: root/kmicromail/nntpgroups.cpp
blob: d2213d4bfdb913dc0b6d343ce8b02de72bb7c299 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "nntpgroups.h"

#include <libmailwrapper/settings.h>
#include <q3listview.h>
#include <qlineedit.h>

using namespace Opie::Core;

NNTPGroups::NNTPGroups(NNTPaccount *account, QWidget* parent, const char* name, Qt::WFlags fl)
    : NNTPGroupsUI(parent,name,fl),subscribedGroups()
{
    m_Account = account;
    fillGroups();
}

NNTPGroups::~NNTPGroups()
{
    
}

void NNTPGroups::slotGetNG()
{
    if (!m_Account) return;
    GroupListView->clear();
    NNTPwrapper tmp( m_Account );
    QString filter = Groupfilteredit->text();
    QStringList list =  tmp.listAllNewsgroups(filter);
    subscribedGroupsNotListed = subscribedGroups;
    for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
         Q3CheckListItem *item;
         item = new Q3CheckListItem( GroupListView, (*it), Q3CheckListItem::CheckBox );
         if ( subscribedGroups.contains( (*it) ) >= 1 ) {
             item->setOn( true );
             subscribedGroupsNotListed.remove((*it));
         }
    }
}

void NNTPGroups::fillGroups()
{
    if (!m_Account) return;
    subscribedGroups = m_Account->getGroups();
    for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
         Q3CheckListItem *item;
         item = new Q3CheckListItem( GroupListView, (*it), Q3CheckListItem::CheckBox );
         item->setOn( true );
    }
}

void NNTPGroups::storeValues()
{
    if (!m_Account) return;
    Q3ListViewItemIterator list_it( GroupListView );
    subscribedGroups.clear();
    for ( ; list_it.current(); ++list_it ) {
        if ( ( (Q3CheckListItem*)list_it.current() )->isOn() ) {
            subscribedGroups.append(  list_it.current()->text(0) );
        }
    }
    subscribedGroups+=subscribedGroupsNotListed;
    m_Account->setGroups( subscribedGroups );
}