summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calfilter.cpp29
-rw-r--r--libkcal/calfilter.h3
2 files changed, 22 insertions, 10 deletions
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index c182db5..c425dfc 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -55,55 +55,66 @@ void CalFilter::apply(QPtrList<Event> *eventlist)
55 } else { 55 } else {
56 event = eventlist->next(); 56 event = eventlist->next();
57 } 57 }
58 } 58 }
59 59
60// kdDebug(5800) << "CalFilter::apply() done" << endl; 60// kdDebug(5800) << "CalFilter::apply() done" << endl;
61} 61}
62 62
63// TODO: avoid duplicating apply() code 63// TODO: avoid duplicating apply() code
64void CalFilter::apply(QPtrList<Todo> *eventlist) 64void CalFilter::apply(QPtrList<Todo> *eventlist)
65{ 65{
66 if (!mEnabled) return; 66 if (!mEnabled) return;
67
68// kdDebug(5800) << "CalFilter::apply()" << endl;
69
70 Todo *event = eventlist->first(); 67 Todo *event = eventlist->first();
71 while(event) { 68 while(event) {
72 if (!filterTodo(event)) { 69 if (!filterTodo(event)) {
73 eventlist->remove(); 70 eventlist->remove();
74 event = eventlist->current(); 71 event = eventlist->current();
75 } else { 72 } else {
76 event = eventlist->next(); 73 event = eventlist->next();
77 } 74 }
78 } 75 }
79 76
80// kdDebug(5800) << "CalFilter::apply() done" << endl; 77// kdDebug(5800) << "CalFilter::apply() done" << endl;
81} 78}
82 79bool CalFilter::filterCalendarItem(Incidence *in)
80{
81 if ( in->type() == "Event" )
82 return filterEvent( (Event*) in );
83 else if ( in->type() =="Todo" )
84 return filterTodo( (Todo*) in);
85 else if ( in->type() =="Journal" )
86 return filterJournal( (Journal*) in );
87 return false;
88}
83bool CalFilter::filterEvent(Event *event) 89bool CalFilter::filterEvent(Event *event)
84{ 90{
85// kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; 91 if (mCriteria & HideEvents)
86 92 return false;
87 if (mCriteria & HideRecurring) { 93 if (mCriteria & HideRecurring) {
88 if (event->recurrence()->doesRecur()) return false; 94 if (event->recurrence()->doesRecur()) return false;
89 } 95 }
90 96
91 return filterIncidence(event); 97 return filterIncidence(event);
92} 98}
93 99bool CalFilter::filterJournal(Journal *j)
100{
101 if (mCriteria & HideJournals)
102 return false;
103 return true;
104}
94bool CalFilter::filterTodo(Todo *todo) 105bool CalFilter::filterTodo(Todo *todo)
95{ 106{
96// kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; 107 if (mCriteria & HideTodos)
97 108 return false;
98 if (mCriteria & HideCompleted) { 109 if (mCriteria & HideCompleted) {
99 if (todo->isCompleted()) return false; 110 if (todo->isCompleted()) return false;
100 } 111 }
101 112
102 return filterIncidence(todo); 113 return filterIncidence(todo);
103} 114}
104bool CalFilter::showCategories() 115bool CalFilter::showCategories()
105{ 116{
106 return mCriteria & ShowCategories; 117 return mCriteria & ShowCategories;
107} 118}
108int CalFilter::getSecrecy() 119int CalFilter::getSecrecy()
109{ 120{
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index 5ad0064..29db441 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -52,25 +52,26 @@ class CalFilter {
52 52
53 /** 53 /**
54 Apply filter to eventlist, all events not matching filter criterias are 54 Apply filter to eventlist, all events not matching filter criterias are
55 removed from the list. 55 removed from the list.
56 */ 56 */
57 void apply(QPtrList<Event> *eventlist); 57 void apply(QPtrList<Event> *eventlist);
58 58
59 /** 59 /**
60 Apply filter to todolist, all todos not matching filter criterias are 60 Apply filter to todolist, all todos not matching filter criterias are
61 removed from the list. 61 removed from the list.
62 */ 62 */
63 void apply(QPtrList<Todo> *todolist); 63 void apply(QPtrList<Todo> *todolist);
64 64 bool CalFilter::filterCalendarItem(Incidence *in);
65 bool CalFilter::filterJournal(Journal *in);
65 /** 66 /**
66 Apply filter criteria on the specified event. Return true, if event passes 67 Apply filter criteria on the specified event. Return true, if event passes
67 criteria, otherwise return false. 68 criteria, otherwise return false.
68 */ 69 */
69 bool filterEvent(Event *); 70 bool filterEvent(Event *);
70 71
71 /** 72 /**
72 Apply filter criteria on the specified todo. Return true, if event passes 73 Apply filter criteria on the specified todo. Return true, if event passes
73 criteria, otherwise return false. 74 criteria, otherwise return false.
74 */ 75 */
75 bool filterTodo(Todo *); 76 bool filterTodo(Todo *);
76 77