Diffstat (limited to 'noncore/net/mail/nntpgroups.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/nntpgroups.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/noncore/net/mail/nntpgroups.cpp b/noncore/net/mail/nntpgroups.cpp new file mode 100644 index 0000000..97b1985 --- a/dev/null +++ b/noncore/net/mail/nntpgroups.cpp | |||
@@ -0,0 +1,57 @@ | |||
1 | #include "nntpgroups.h" | ||
2 | |||
3 | #include <libmailwrapper/settings.h> | ||
4 | |||
5 | #include <qlistview.h> | ||
6 | |||
7 | NNTPGroups::NNTPGroups(NNTPaccount *account, QWidget* parent, const char* name, WFlags fl) | ||
8 | : NNTPGroupsUI(parent,name,fl),subscribedGroups() | ||
9 | { | ||
10 | m_Account = account; | ||
11 | fillGroups(); | ||
12 | } | ||
13 | |||
14 | NNTPGroups::~NNTPGroups() | ||
15 | { | ||
16 | |||
17 | } | ||
18 | |||
19 | void NNTPGroups::slotGetNG() | ||
20 | { | ||
21 | if (!m_Account) return; | ||
22 | GroupListView->clear(); | ||
23 | NNTPwrapper tmp( m_Account ); | ||
24 | QStringList list = tmp.listAllNewsgroups(); | ||
25 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | ||
26 | QCheckListItem *item; | ||
27 | item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox ); | ||
28 | if ( subscribedGroups.contains( (*it) ) >= 1 ) { | ||
29 | item->setOn( true ); | ||
30 | } | ||
31 | } | ||
32 | } | ||
33 | |||
34 | void NNTPGroups::fillGroups() | ||
35 | { | ||
36 | if (!m_Account) return; | ||
37 | subscribedGroups = m_Account->getGroups(); | ||
38 | for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { | ||
39 | QCheckListItem *item; | ||
40 | item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox ); | ||
41 | item->setOn( true ); | ||
42 | } | ||
43 | } | ||
44 | |||
45 | void NNTPGroups::storeValues() | ||
46 | { | ||
47 | if (!m_Account) return; | ||
48 | QListViewItemIterator list_it( GroupListView ); | ||
49 | subscribedGroups.clear(); | ||
50 | for ( ; list_it.current(); ++list_it ) { | ||
51 | if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { | ||
52 | qDebug(list_it.current()->text(0) ); | ||
53 | subscribedGroups.append( list_it.current()->text(0) ); | ||
54 | } | ||
55 | } | ||
56 | m_Account->setGroups( subscribedGroups ); | ||
57 | } | ||