author | zautrix <zautrix> | 2005-01-16 11:22:49 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-16 11:22:49 (UTC) |
commit | d57ed4438bbd6e3d9a7a0e46283d3e7645b4e47b (patch) (unidiff) | |
tree | 522438ce187845f6d74d7888be203759138615fa | |
parent | 92b8de5ff678bddf69b9f0a45c1d90829c50c592 (diff) | |
download | kdepimpi-d57ed4438bbd6e3d9a7a0e46283d3e7645b4e47b.zip kdepimpi-d57ed4438bbd6e3d9a7a0e46283d3e7645b4e47b.tar.gz kdepimpi-d57ed4438bbd6e3d9a7a0e46283d3e7645b4e47b.tar.bz2 |
filter impl
-rw-r--r-- | korganizer/calendarview.cpp | 8 | ||||
-rw-r--r-- | korganizer/filtereditdialog.cpp | 7 | ||||
-rw-r--r-- | libkcal/calfilter.cpp | 29 | ||||
-rw-r--r-- | libkcal/calfilter.h | 3 |
4 files changed, 37 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8258c74..02c5e45 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1077,6 +1077,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1077 | //remote->deleteIncidence( inR ); | 1077 | //remote->deleteIncidence( inR ); |
1078 | ++deletedEventR; | 1078 | ++deletedEventR; |
1079 | } else { | 1079 | } else { |
1080 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | ||
1080 | inR->setLastModified( modifiedCalendar ); | 1081 | inR->setLastModified( modifiedCalendar ); |
1081 | inL = inR->clone(); | 1082 | inL = inR->clone(); |
1082 | inL->setIDStr( ":" ); | 1083 | inL->setIDStr( ":" ); |
@@ -1085,13 +1086,16 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1085 | local->addIncidence( inL ); | 1086 | local->addIncidence( inL ); |
1086 | ++addedEvent; | 1087 | ++addedEvent; |
1087 | } | 1088 | } |
1089 | } | ||
1088 | } else { | 1090 | } else { |
1089 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1091 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1092 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | ||
1090 | inR->setLastModified( modifiedCalendar ); | 1093 | inR->setLastModified( modifiedCalendar ); |
1091 | inL = inR->clone(); | 1094 | inL = inR->clone(); |
1092 | inL->setIDStr( ":" ); | 1095 | inL->setIDStr( ":" ); |
1093 | local->addIncidence( inL ); | 1096 | local->addIncidence( inL ); |
1094 | ++addedEvent; | 1097 | ++addedEvent; |
1098 | } | ||
1095 | } else { | 1099 | } else { |
1096 | checkExternSyncEvent(eventRSyncSharp, inR); | 1100 | checkExternSyncEvent(eventRSyncSharp, inR); |
1097 | remote->deleteIncidence( inR ); | 1101 | remote->deleteIncidence( inR ); |
@@ -1134,6 +1138,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1134 | ++deletedEventL; | 1138 | ++deletedEventL; |
1135 | } else { | 1139 | } else { |
1136 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1140 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1141 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | ||
1137 | inL->removeID(mCurrentSyncDevice ); | 1142 | inL->removeID(mCurrentSyncDevice ); |
1138 | ++addedEventR; | 1143 | ++addedEventR; |
1139 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1144 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
@@ -1144,6 +1149,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1144 | remote->addIncidence( inR ); | 1149 | remote->addIncidence( inR ); |
1145 | } | 1150 | } |
1146 | } | 1151 | } |
1152 | } | ||
1147 | } else { | 1153 | } else { |
1148 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1154 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1149 | checkExternSyncEvent(eventLSyncSharp, inL); | 1155 | checkExternSyncEvent(eventLSyncSharp, inL); |
@@ -1151,6 +1157,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1151 | ++deletedEventL; | 1157 | ++deletedEventL; |
1152 | } else { | 1158 | } else { |
1153 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1159 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1160 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | ||
1154 | ++addedEventR; | 1161 | ++addedEventR; |
1155 | inL->setLastModified( modifiedCalendar ); | 1162 | inL->setLastModified( modifiedCalendar ); |
1156 | inR = inL->clone(); | 1163 | inR = inL->clone(); |
@@ -1161,6 +1168,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1161 | } | 1168 | } |
1162 | } | 1169 | } |
1163 | } | 1170 | } |
1171 | } | ||
1164 | inL = el.next(); | 1172 | inL = el.next(); |
1165 | } | 1173 | } |
1166 | int delFut = 0; | 1174 | int delFut = 0; |
diff --git a/korganizer/filtereditdialog.cpp b/korganizer/filtereditdialog.cpp index ca09844..df84911 100644 --- a/korganizer/filtereditdialog.cpp +++ b/korganizer/filtereditdialog.cpp | |||
@@ -236,6 +236,10 @@ void FilterEditDialog::readFilter(CalFilter *filter) | |||
236 | mEditor->mPrivateCheck->setChecked(c & CalFilter::ShowPrivate); | 236 | mEditor->mPrivateCheck->setChecked(c & CalFilter::ShowPrivate); |
237 | mEditor->mConfidentialCheck->setChecked(c & CalFilter::ShowConfidential); | 237 | mEditor->mConfidentialCheck->setChecked(c & CalFilter::ShowConfidential); |
238 | 238 | ||
239 | mEditor->mEventCheck->setChecked(c & CalFilter::HideEvents); | ||
240 | mEditor->mTodoCheck->setChecked(c & CalFilter::HideTodos); | ||
241 | mEditor->mJournalCheck->setChecked(c & CalFilter::HideJournals); | ||
242 | |||
239 | if (c & CalFilter::ShowCategories) { | 243 | if (c & CalFilter::ShowCategories) { |
240 | mEditor->mCatShowCheck->setChecked(true); | 244 | mEditor->mCatShowCheck->setChecked(true); |
241 | } else { | 245 | } else { |
@@ -259,6 +263,9 @@ void FilterEditDialog::writeFilter(CalFilter *filter) | |||
259 | if (mEditor->mPublicCheck->isChecked()) c |= CalFilter::ShowPublic; | 263 | if (mEditor->mPublicCheck->isChecked()) c |= CalFilter::ShowPublic; |
260 | if (mEditor->mPrivateCheck->isChecked()) c |= CalFilter::ShowPrivate; | 264 | if (mEditor->mPrivateCheck->isChecked()) c |= CalFilter::ShowPrivate; |
261 | if (mEditor->mConfidentialCheck->isChecked()) c |= CalFilter::ShowConfidential; | 265 | if (mEditor->mConfidentialCheck->isChecked()) c |= CalFilter::ShowConfidential; |
266 | if (mEditor->mEventCheck->isChecked()) c |= CalFilter::HideEvents; | ||
267 | if (mEditor->mTodoCheck->isChecked()) c |= CalFilter::HideTodos; | ||
268 | if (mEditor->mJournalCheck->isChecked()) c |= CalFilter::HideJournals; | ||
262 | 269 | ||
263 | filter->setCriteria(c); | 270 | filter->setCriteria(c); |
264 | 271 | ||
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp index c182db5..c425dfc 100644 --- a/libkcal/calfilter.cpp +++ b/libkcal/calfilter.cpp | |||
@@ -64,9 +64,6 @@ void CalFilter::apply(QPtrList<Event> *eventlist) | |||
64 | void CalFilter::apply(QPtrList<Todo> *eventlist) | 64 | void 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)) { |
@@ -79,22 +76,36 @@ void CalFilter::apply(QPtrList<Todo> *eventlist) | |||
79 | 76 | ||
80 | // kdDebug(5800) << "CalFilter::apply() done" << endl; | 77 | // kdDebug(5800) << "CalFilter::apply() done" << endl; |
81 | } | 78 | } |
82 | 79 | bool 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 | } | ||
83 | bool CalFilter::filterEvent(Event *event) | 89 | bool 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 | 99 | bool CalFilter::filterJournal(Journal *j) | |
100 | { | ||
101 | if (mCriteria & HideJournals) | ||
102 | return false; | ||
103 | return true; | ||
104 | } | ||
94 | bool CalFilter::filterTodo(Todo *todo) | 105 | bool 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 | } |
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h index 5ad0064..29db441 100644 --- a/libkcal/calfilter.h +++ b/libkcal/calfilter.h | |||
@@ -61,7 +61,8 @@ class CalFilter { | |||
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. |