summaryrefslogtreecommitdiff
authoralwin <alwin>2004-03-07 02:18:47 (UTC)
committer alwin <alwin>2004-03-07 02:18:47 (UTC)
commite1c0bbc4fafe709ceed8f4a046c4bff7d4ba30ff (patch) (unidiff)
tree5c7bc290c2f2e262749c93023a4a5c2b7249bd92
parentdf4f3107d45976d9276ef96df4683822cf05d38c (diff)
downloadopie-e1c0bbc4fafe709ceed8f4a046c4bff7d4ba30ff.zip
opie-e1c0bbc4fafe709ceed8f4a046c4bff7d4ba30ff.tar.gz
opie-e1c0bbc4fafe709ceed8f4a046c4bff7d4ba30ff.tar.bz2
filter for newsgroups works
ToDo: we should cache the list of newsgroups!
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/nntpgroups.cpp7
-rw-r--r--noncore/net/mail/nntpgroups.h2
-rw-r--r--noncore/net/mail/nntpgroupsui.ui49
3 files changed, 52 insertions, 6 deletions
diff --git a/noncore/net/mail/nntpgroups.cpp b/noncore/net/mail/nntpgroups.cpp
index 97b1985..8741c4b 100644
--- a/noncore/net/mail/nntpgroups.cpp
+++ b/noncore/net/mail/nntpgroups.cpp
@@ -1,57 +1,62 @@
1#include "nntpgroups.h" 1#include "nntpgroups.h"
2 2
3#include <libmailwrapper/settings.h> 3#include <libmailwrapper/settings.h>
4 4
5#include <qlistview.h> 5#include <qlistview.h>
6#include <qlineedit.h>
6 7
7NNTPGroups::NNTPGroups(NNTPaccount *account, QWidget* parent, const char* name, WFlags fl) 8NNTPGroups::NNTPGroups(NNTPaccount *account, QWidget* parent, const char* name, WFlags fl)
8 : NNTPGroupsUI(parent,name,fl),subscribedGroups() 9 : NNTPGroupsUI(parent,name,fl),subscribedGroups()
9{ 10{
10 m_Account = account; 11 m_Account = account;
11 fillGroups(); 12 fillGroups();
12} 13}
13 14
14NNTPGroups::~NNTPGroups() 15NNTPGroups::~NNTPGroups()
15{ 16{
16 17
17} 18}
18 19
19void NNTPGroups::slotGetNG() 20void NNTPGroups::slotGetNG()
20{ 21{
21 if (!m_Account) return; 22 if (!m_Account) return;
22 GroupListView->clear(); 23 GroupListView->clear();
23 NNTPwrapper tmp( m_Account ); 24 NNTPwrapper tmp( m_Account );
24 QStringList list = tmp.listAllNewsgroups(); 25 QString filter = Groupfilteredit->text();
26 QStringList list = tmp.listAllNewsgroups(filter);
27 subscribedGroupsNotListed = subscribedGroups;
25 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 28 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
26 QCheckListItem *item; 29 QCheckListItem *item;
27 item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox ); 30 item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox );
28 if ( subscribedGroups.contains( (*it) ) >= 1 ) { 31 if ( subscribedGroups.contains( (*it) ) >= 1 ) {
29 item->setOn( true ); 32 item->setOn( true );
33 subscribedGroupsNotListed.remove((*it));
30 } 34 }
31 } 35 }
32} 36}
33 37
34void NNTPGroups::fillGroups() 38void NNTPGroups::fillGroups()
35{ 39{
36 if (!m_Account) return; 40 if (!m_Account) return;
37 subscribedGroups = m_Account->getGroups(); 41 subscribedGroups = m_Account->getGroups();
38 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { 42 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
39 QCheckListItem *item; 43 QCheckListItem *item;
40 item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox ); 44 item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox );
41 item->setOn( true ); 45 item->setOn( true );
42 } 46 }
43} 47}
44 48
45void NNTPGroups::storeValues() 49void NNTPGroups::storeValues()
46{ 50{
47 if (!m_Account) return; 51 if (!m_Account) return;
48 QListViewItemIterator list_it( GroupListView ); 52 QListViewItemIterator list_it( GroupListView );
49 subscribedGroups.clear(); 53 subscribedGroups.clear();
50 for ( ; list_it.current(); ++list_it ) { 54 for ( ; list_it.current(); ++list_it ) {
51 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { 55 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) {
52 qDebug(list_it.current()->text(0) ); 56 qDebug(list_it.current()->text(0) );
53 subscribedGroups.append( list_it.current()->text(0) ); 57 subscribedGroups.append( list_it.current()->text(0) );
54 } 58 }
55 } 59 }
60 subscribedGroups+=subscribedGroupsNotListed;
56 m_Account->setGroups( subscribedGroups ); 61 m_Account->setGroups( subscribedGroups );
57} 62}
diff --git a/noncore/net/mail/nntpgroups.h b/noncore/net/mail/nntpgroups.h
index 8cc2e8b..e5b7c35 100644
--- a/noncore/net/mail/nntpgroups.h
+++ b/noncore/net/mail/nntpgroups.h
@@ -1,33 +1,33 @@
1#ifndef __NNTPGROUPS_WINDOW__ 1#ifndef __NNTPGROUPS_WINDOW__
2#define __NNTPGROUPS_WINDOW__ 2#define __NNTPGROUPS_WINDOW__
3 3
4#include "nntpgroupsui.h" 4#include "nntpgroupsui.h"
5 5
6#include <libmailwrapper/nntpwrapper.h> 6#include <libmailwrapper/nntpwrapper.h>
7 7
8class NNTPaccount; 8class NNTPaccount;
9class QStringList; 9class QStringList;
10 10
11class NNTPGroups:public NNTPGroupsUI 11class NNTPGroups:public NNTPGroupsUI
12{ 12{
13 Q_OBJECT 13 Q_OBJECT
14public: 14public:
15 NNTPGroups(NNTPaccount *account, QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 15 NNTPGroups(NNTPaccount *account, QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
16 virtual ~NNTPGroups(); 16 virtual ~NNTPGroups();
17 /* must be called from external. 17 /* must be called from external.
18 * it will store the new subscription list into the account 18 * it will store the new subscription list into the account
19 * but don't save them, this must be done by the calling class. 19 * but don't save them, this must be done by the calling class.
20 */ 20 */
21 void storeValues(); 21 void storeValues();
22 22
23protected slots: 23protected slots:
24 virtual void slotGetNG(); 24 virtual void slotGetNG();
25 25
26protected: 26protected:
27 virtual void fillGroups(); 27 virtual void fillGroups();
28 28
29 NNTPaccount*m_Account; 29 NNTPaccount*m_Account;
30 QStringList subscribedGroups; 30 QStringList subscribedGroups,subscribedGroupsNotListed;
31}; 31};
32 32
33#endif 33#endif
diff --git a/noncore/net/mail/nntpgroupsui.ui b/noncore/net/mail/nntpgroupsui.ui
index 93f487b..2902731 100644
--- a/noncore/net/mail/nntpgroupsui.ui
+++ b/noncore/net/mail/nntpgroupsui.ui
@@ -1,88 +1,129 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>NNTPGroupsUI</class> 2<class>NNTPGroupsUI</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>NNTPGroupsUI</cstring> 7 <cstring>NNTPGroupsUI</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>356</width> 14 <width>254</width>
15 <height>406</height> 15 <height>330</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>newsgroupslist</string> 20 <string>newsgroupslist</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <vbox> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>2</number> 31 <number>1</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>2</number> 35 <number>1</number>
36 </property> 36 </property>
37 <widget> 37 <widget>
38 <class>QListView</class> 38 <class>QListView</class>
39 <column> 39 <column>
40 <property> 40 <property>
41 <name>text</name> 41 <name>text</name>
42 <string>Newsgroups</string> 42 <string>Newsgroups</string>
43 </property> 43 </property>
44 <property> 44 <property>
45 <name>clickable</name> 45 <name>clickable</name>
46 <bool>true</bool> 46 <bool>true</bool>
47 </property> 47 </property>
48 <property> 48 <property>
49 <name>resizeable</name> 49 <name>resizeable</name>
50 <bool>true</bool> 50 <bool>true</bool>
51 </property> 51 </property>
52 </column> 52 </column>
53 <property stdset="1"> 53 <property stdset="1">
54 <name>name</name> 54 <name>name</name>
55 <cstring>GroupListView</cstring> 55 <cstring>GroupListView</cstring>
56 </property> 56 </property>
57 <property> 57 <property>
58 <name>whatsThis</name> 58 <name>whatsThis</name>
59 <string>List of groups from the server. On start, only subscribed groups are listed.</string> 59 <string>List of groups from the server. On start, only subscribed groups are listed.</string>
60 </property> 60 </property>
61 </widget> 61 </widget>
62 <widget> 62 <widget>
63 <class>QLayoutWidget</class>
64 <property stdset="1">
65 <name>name</name>
66 <cstring>Layout1</cstring>
67 </property>
68 <hbox>
69 <property stdset="1">
70 <name>margin</name>
71 <number>0</number>
72 </property>
73 <property stdset="1">
74 <name>spacing</name>
75 <number>6</number>
76 </property>
77 <widget>
78 <class>QLabel</class>
79 <property stdset="1">
80 <name>name</name>
81 <cstring>filterlabel</cstring>
82 </property>
83 <property stdset="1">
84 <name>text</name>
85 <string>Groupfilter:</string>
86 </property>
87 </widget>
88 <widget>
89 <class>QLineEdit</class>
90 <property stdset="1">
91 <name>name</name>
92 <cstring>Groupfilteredit</cstring>
93 </property>
94 <property>
95 <name>whatsThis</name>
96 <string>Enter a filter string here.
97Then hit "get newsgroup list" again and only groups starting
98with that filter will be listet.</string>
99 </property>
100 </widget>
101 </hbox>
102 </widget>
103 <widget>
63 <class>QPushButton</class> 104 <class>QPushButton</class>
64 <property stdset="1"> 105 <property stdset="1">
65 <name>name</name> 106 <name>name</name>
66 <cstring>GetNGButton</cstring> 107 <cstring>GetNGButton</cstring>
67 </property> 108 </property>
68 <property stdset="1"> 109 <property stdset="1">
69 <name>text</name> 110 <name>text</name>
70 <string>Get newsgroup list from server</string> 111 <string>Get newsgroup list from server</string>
71 </property> 112 </property>
72 <property> 113 <property>
73 <name>whatsThis</name> 114 <name>whatsThis</name>
74 <string>Retrieve the list of groups from server</string> 115 <string>Retrieve the list of groups from server</string>
75 </property> 116 </property>
76 </widget> 117 </widget>
77 </vbox> 118 </vbox>
78</widget> 119</widget>
79<connections> 120<connections>
80 <connection> 121 <connection>
81 <sender>GetNGButton</sender> 122 <sender>GetNGButton</sender>
82 <signal>clicked()</signal> 123 <signal>clicked()</signal>
83 <receiver>NNTPGroupsUI</receiver> 124 <receiver>NNTPGroupsUI</receiver>
84 <slot>slotGetNG()</slot> 125 <slot>slotGetNG()</slot>
85 </connection> 126 </connection>
86 <slot access="protected">slotGetNG()</slot> 127 <slot access="protected">slotGetNG()</slot>
87</connections> 128</connections>
88</UI> 129</UI>