summaryrefslogtreecommitdiffabout
path: root/libkcal/calfilter.cpp
Unidiff
Diffstat (limited to 'libkcal/calfilter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calfilter.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index 72f70c2..fa1dbd5 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -1,221 +1,223 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kdebug.h> 21#include <kdebug.h>
22 22
23#include "calfilter.h" 23#include "calfilter.h"
24//Added by qt3to4:
25#include <Q3PtrList>
24 26
25using namespace KCal; 27using namespace KCal;
26 28
27CalFilter::CalFilter() 29CalFilter::CalFilter()
28{ 30{
29 mEnabled = true; 31 mEnabled = true;
30 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 32 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
31} 33}
32 34
33CalFilter::CalFilter(const QString &name) 35CalFilter::CalFilter(const QString &name)
34{ 36{
35 mName = name; 37 mName = name;
36 mEnabled = true; 38 mEnabled = true;
37 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 39 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
38} 40}
39 41
40CalFilter::~CalFilter() 42CalFilter::~CalFilter()
41{ 43{
42} 44}
43 45
44void CalFilter::apply(QPtrList<Event> *eventlist) 46void CalFilter::apply(Q3PtrList<Event> *eventlist)
45{ 47{
46 if (!mEnabled) return; 48 if (!mEnabled) return;
47 49
48// kdDebug(5800) << "CalFilter::apply()" << endl; 50// kdDebug(5800) << "CalFilter::apply()" << endl;
49 51
50 Event *event = eventlist->first(); 52 Event *event = eventlist->first();
51 while(event) { 53 while(event) {
52 if (!filterEvent(event)) { 54 if (!filterEvent(event)) {
53 eventlist->remove(); 55 eventlist->remove();
54 event = eventlist->current(); 56 event = eventlist->current();
55 } else { 57 } else {
56 event = eventlist->next(); 58 event = eventlist->next();
57 } 59 }
58 } 60 }
59 61
60// kdDebug(5800) << "CalFilter::apply() done" << endl; 62// kdDebug(5800) << "CalFilter::apply() done" << endl;
61} 63}
62 64
63// TODO: avoid duplicating apply() code 65// TODO: avoid duplicating apply() code
64void CalFilter::apply(QPtrList<Todo> *eventlist) 66void CalFilter::apply(Q3PtrList<Todo> *eventlist)
65{ 67{
66 if (!mEnabled) return; 68 if (!mEnabled) return;
67 Todo *event = eventlist->first(); 69 Todo *event = eventlist->first();
68 while(event) { 70 while(event) {
69 if (!filterTodo(event)) { 71 if (!filterTodo(event)) {
70 eventlist->remove(); 72 eventlist->remove();
71 event = eventlist->current(); 73 event = eventlist->current();
72 } else { 74 } else {
73 event = eventlist->next(); 75 event = eventlist->next();
74 } 76 }
75 } 77 }
76 78
77// kdDebug(5800) << "CalFilter::apply() done" << endl; 79// kdDebug(5800) << "CalFilter::apply() done" << endl;
78} 80}
79bool CalFilter::filterCalendarItem(Incidence *in) 81bool CalFilter::filterCalendarItem(Incidence *in)
80{ 82{
81 if ( !in->calEnabled() ) 83 if ( !in->calEnabled() )
82 return false; 84 return false;
83 if ( in->typeID() == eventID ) 85 if ( in->typeID() == eventID )
84 return filterEvent( (Event*) in ); 86 return filterEvent( (Event*) in );
85 else if ( in->typeID() == todoID ) 87 else if ( in->typeID() == todoID )
86 return filterTodo( (Todo*) in); 88 return filterTodo( (Todo*) in);
87 else if ( in->typeID () == journalID ) 89 else if ( in->typeID () == journalID )
88 return filterJournal( (Journal*) in ); 90 return filterJournal( (Journal*) in );
89 return false; 91 return false;
90} 92}
91bool CalFilter::filterEvent(Event *event) 93bool CalFilter::filterEvent(Event *event)
92{ 94{
93 95
94 if ( !event->calEnabled() ) 96 if ( !event->calEnabled() )
95 return false; 97 return false;
96 if (mCriteria & HideEvents) 98 if (mCriteria & HideEvents)
97 return false; 99 return false;
98 if (mCriteria & HideRecurring) { 100 if (mCriteria & HideRecurring) {
99 if (event->recurrence()->doesRecur()) return false; 101 if (event->recurrence()->doesRecur()) return false;
100 } 102 }
101 103
102 return filterIncidence(event); 104 return filterIncidence(event);
103} 105}
104bool CalFilter::filterJournal(Journal *j) 106bool CalFilter::filterJournal(Journal *j)
105{ 107{
106 if ( !j->calEnabled() ) 108 if ( !j->calEnabled() )
107 return false; 109 return false;
108 if (mCriteria & HideJournals) 110 if (mCriteria & HideJournals)
109 return false; 111 return false;
110 return true; 112 return true;
111} 113}
112bool CalFilter::filterTodo(Todo *todo) 114bool CalFilter::filterTodo(Todo *todo)
113{ 115{
114 if ( !todo->calEnabled() ) 116 if ( !todo->calEnabled() )
115 return false; 117 return false;
116 if (mCriteria & HideTodos) 118 if (mCriteria & HideTodos)
117 return false; 119 return false;
118 if (mCriteria & HideCompleted) { 120 if (mCriteria & HideCompleted) {
119 if (todo->isCompleted()) return false; 121 if (todo->isCompleted()) return false;
120 } 122 }
121 123
122 return filterIncidence(todo); 124 return filterIncidence(todo);
123} 125}
124bool CalFilter::showCategories() 126bool CalFilter::showCategories()
125{ 127{
126 return mCriteria & ShowCategories; 128 return mCriteria & ShowCategories;
127} 129}
128int CalFilter::getSecrecy() 130int CalFilter::getSecrecy()
129{ 131{
130 if ( (mCriteria & ShowPublic )) 132 if ( (mCriteria & ShowPublic ))
131 return Incidence::SecrecyPublic; 133 return Incidence::SecrecyPublic;
132 if ( (mCriteria & ShowPrivate )) 134 if ( (mCriteria & ShowPrivate ))
133 return Incidence::SecrecyPrivate; 135 return Incidence::SecrecyPrivate;
134 if ( (mCriteria & ShowConfidential )) 136 if ( (mCriteria & ShowConfidential ))
135 return Incidence::SecrecyConfidential; 137 return Incidence::SecrecyConfidential;
136 return Incidence::SecrecyPublic; 138 return Incidence::SecrecyPublic;
137} 139}
138bool CalFilter::filterIncidence(Incidence *incidence) 140bool CalFilter::filterIncidence(Incidence *incidence)
139{ 141{
140 if ( mCriteria > 7 ) { 142 if ( mCriteria > 7 ) {
141 switch (incidence->secrecy()) { 143 switch (incidence->secrecy()) {
142 case Incidence::SecrecyPublic: 144 case Incidence::SecrecyPublic:
143 if (! (mCriteria & ShowPublic )) 145 if (! (mCriteria & ShowPublic ))
144 return false; 146 return false;
145 break; 147 break;
146 case Incidence::SecrecyPrivate: 148 case Incidence::SecrecyPrivate:
147 if (! (mCriteria & ShowPrivate )) 149 if (! (mCriteria & ShowPrivate ))
148 return false; 150 return false;
149 break; 151 break;
150 case Incidence::SecrecyConfidential: 152 case Incidence::SecrecyConfidential:
151 if (! (mCriteria & ShowConfidential )) 153 if (! (mCriteria & ShowConfidential ))
152 return false; 154 return false;
153 break; 155 break;
154 default: 156 default:
155 return false; 157 return false;
156 break; 158 break;
157 } 159 }
158 } 160 }
159 161
160 // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; 162 // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl;
161 163
162 if (mCriteria & ShowCategories) { 164 if (mCriteria & ShowCategories) {
163 for (QStringList::Iterator it = mCategoryList.begin(); 165 for (QStringList::Iterator it = mCategoryList.begin();
164 it != mCategoryList.end(); ++it ) { 166 it != mCategoryList.end(); ++it ) {
165 //QStringList incidenceCategories = incidence->categories(); 167 //QStringList incidenceCategories = incidence->categories();
166 for (QStringList::Iterator it2 = incidence->categoriesP()->begin(); 168 for (QStringList::Iterator it2 = incidence->categoriesP()->begin();
167 it2 != incidence->categoriesP()->end(); ++it2 ) { 169 it2 != incidence->categoriesP()->end(); ++it2 ) {
168 if ((*it) == (*it2)) { 170 if ((*it) == (*it2)) {
169 return true; 171 return true;
170 } 172 }
171 } 173 }
172 } 174 }
173 return false; 175 return false;
174 } else { 176 } else {
175 for (QStringList::Iterator it = mCategoryList.begin(); 177 for (QStringList::Iterator it = mCategoryList.begin();
176 it != mCategoryList.end(); ++it ) { 178 it != mCategoryList.end(); ++it ) {
177 //QStringList incidenceCategories = incidence->categories(); 179 //QStringList incidenceCategories = incidence->categories();
178 for (QStringList::Iterator it2 = incidence->categoriesP()->begin(); 180 for (QStringList::Iterator it2 = incidence->categoriesP()->begin();
179 it2 != incidence->categoriesP()->end(); ++it2 ) { 181 it2 != incidence->categoriesP()->end(); ++it2 ) {
180 if ((*it) == (*it2)) { 182 if ((*it) == (*it2)) {
181 return false; 183 return false;
182 } 184 }
183 } 185 }
184 } 186 }
185 return true; 187 return true;
186 } 188 }
187 189
188// kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl; 190// kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl;
189 191
190 return true; 192 return true;
191} 193}
192 194
193void CalFilter::setEnabled(bool enabled) 195void CalFilter::setEnabled(bool enabled)
194{ 196{
195 mEnabled = enabled; 197 mEnabled = enabled;
196} 198}
197 199
198bool CalFilter::isEnabled() 200bool CalFilter::isEnabled()
199{ 201{
200 return mEnabled; 202 return mEnabled;
201} 203}
202 204
203void CalFilter::setCriteria(int criteria) 205void CalFilter::setCriteria(int criteria)
204{ 206{
205 mCriteria = criteria; 207 mCriteria = criteria;
206} 208}
207 209
208int CalFilter::criteria() 210int CalFilter::criteria()
209{ 211{
210 return mCriteria; 212 return mCriteria;
211} 213}
212 214
213void CalFilter::setCategoryList(const QStringList &categoryList) 215void CalFilter::setCategoryList(const QStringList &categoryList)
214{ 216{
215 mCategoryList = categoryList; 217 mCategoryList = categoryList;
216} 218}
217 219
218QStringList CalFilter::categoryList() 220QStringList CalFilter::categoryList()
219{ 221{
220 return mCategoryList; 222 return mCategoryList;
221} 223}