summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-06-14 08:23:19 (UTC)
committer zautrix <zautrix>2005-06-14 08:23:19 (UTC)
commit1dccb9dd9ea32989ecec33c72a3ebd873dce048e (patch) (unidiff)
tree6b7dd7e4696c91a3afaba89225dd4f31f376a30b /libkcal
parentb3743f5abe0a95c9ffeadf6701c9943f604febd6 (diff)
downloadkdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.zip
kdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.tar.gz
kdepimpi-1dccb9dd9ea32989ecec33c72a3ebd873dce048e.tar.bz2
faster filter
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp55
-rw-r--r--libkcal/calfilter.cpp12
-rw-r--r--libkcal/incidence.cpp5
-rw-r--r--libkcal/incidence.h1
4 files changed, 49 insertions, 24 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 749d9f6..336c3e8 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -180,106 +180,110 @@ bool CalendarLocal::addAnniversaryNoDup( Event *event )
180 if ( eve->dtStart().date() != event->dtStart().date() ) 180 if ( eve->dtStart().date() != event->dtStart().date() )
181 continue; 181 continue;
182 // now we have an event with fitting category+date 182 // now we have an event with fitting category+date
183 if ( eve->summary() != event->summary() ) 183 if ( eve->summary() != event->summary() )
184 continue; 184 continue;
185 // now we have an event with fitting category+date+summary 185 // now we have an event with fitting category+date+summary
186 return false; 186 return false;
187 } 187 }
188 return addEvent( event ); 188 return addEvent( event );
189 189
190} 190}
191bool CalendarLocal::addEventNoDup( Event *event ) 191bool CalendarLocal::addEventNoDup( Event *event )
192{ 192{
193 Event * eve; 193 Event * eve;
194 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 194 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
195 if ( *eve == *event ) { 195 if ( *eve == *event ) {
196 //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); 196 //qDebug("CalendarLocal::Duplicate event found! Not inserted! ");
197 return false; 197 return false;
198 } 198 }
199 } 199 }
200 return addEvent( event ); 200 return addEvent( event );
201} 201}
202 202
203bool CalendarLocal::addEvent( Event *event ) 203bool CalendarLocal::addEvent( Event *event )
204{ 204{
205 insertEvent( event ); 205 insertEvent( event );
206 206
207 event->registerObserver( this ); 207 event->registerObserver( this );
208 208
209 setModified( true ); 209 setModified( true );
210 event->setCalID( mDefaultCalendar ); 210 event->setCalID( mDefaultCalendar );
211 event->setCalEnabled( true ); 211 event->setCalEnabled( true );
212 212
213 return true; 213 return true;
214} 214}
215 215
216void CalendarLocal::deleteEvent( Event *event ) 216void CalendarLocal::deleteEvent( Event *event )
217{ 217{
218 if ( mUndoIncidence ) delete mUndoIncidence; 218 if ( mUndoIncidence ) delete mUndoIncidence;
219 mUndoIncidence = event->clone(); 219 mUndoIncidence = event->clone();
220 if ( mEventList.removeRef( event ) ) { 220 if ( mEventList.removeRef( event ) ) {
221 setModified( true ); 221 setModified( true );
222 } 222 }
223} 223}
224 224
225 225
226Event *CalendarLocal::event( const QString &uid ) 226Event *CalendarLocal::event( const QString &uid )
227{ 227{
228 228 Event *event;
229 Event *event; 229 Event *retVal = 0;
230 230 for ( event = mEventList.first(); event; event = mEventList.next() ) {
231 for ( event = mEventList.first(); event; event = mEventList.next() ) { 231 if ( event->calEnabled() && event->uid() == uid ) {
232 if ( event->uid() == uid && event->calEnabled() ) { 232 if ( retVal ) {
233 return event; 233 if ( retVal->calID() > event->calID() ) {
234 retVal = event;
235 }
236 } else {
237 retVal = event;
238 }
239 }
234 } 240 }
235 } 241 return retVal;
236
237 return 0;
238} 242}
239bool CalendarLocal::addTodoNoDup( Todo *todo ) 243bool CalendarLocal::addTodoNoDup( Todo *todo )
240{ 244{
241 Todo * eve; 245 Todo * eve;
242 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { 246 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
243 if ( *eve == *todo ) { 247 if ( *eve == *todo ) {
244 //qDebug("duplicate todo found! not inserted! "); 248 //qDebug("duplicate todo found! not inserted! ");
245 return false; 249 return false;
246 } 250 }
247 } 251 }
248 return addTodo( todo ); 252 return addTodo( todo );
249} 253}
250bool CalendarLocal::addTodo( Todo *todo ) 254bool CalendarLocal::addTodo( Todo *todo )
251{ 255{
252 mTodoList.append( todo ); 256 mTodoList.append( todo );
253 257
254 todo->registerObserver( this ); 258 todo->registerObserver( this );
255 259
256 // Set up subtask relations 260 // Set up subtask relations
257 setupRelations( todo ); 261 setupRelations( todo );
258 262
259 setModified( true ); 263 setModified( true );
260 todo->setCalID( mDefaultCalendar ); 264 todo->setCalID( mDefaultCalendar );
261 todo->setCalEnabled( true ); 265 todo->setCalEnabled( true );
262 return true; 266 return true;
263} 267}
264 268
265void CalendarLocal::deleteTodo( Todo *todo ) 269void CalendarLocal::deleteTodo( Todo *todo )
266{ 270{
267 // Handle orphaned children 271 // Handle orphaned children
268 if ( mUndoIncidence ) delete mUndoIncidence; 272 if ( mUndoIncidence ) delete mUndoIncidence;
269 removeRelations( todo ); 273 removeRelations( todo );
270 mUndoIncidence = todo->clone(); 274 mUndoIncidence = todo->clone();
271 275
272 if ( mTodoList.removeRef( todo ) ) { 276 if ( mTodoList.removeRef( todo ) ) {
273 setModified( true ); 277 setModified( true );
274 } 278 }
275} 279}
276 280
277QPtrList<Todo> CalendarLocal::rawTodos() 281QPtrList<Todo> CalendarLocal::rawTodos()
278{ 282{
279 QPtrList<Todo> el; 283 QPtrList<Todo> el;
280 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 284 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
281 if ( it->calEnabled() ) el.append( it ); 285 if ( it->calEnabled() ) el.append( it );
282 return el; 286 return el;
283} 287}
284Todo *CalendarLocal::todo( QString syncProf, QString id ) 288Todo *CalendarLocal::todo( QString syncProf, QString id )
285{ 289{
@@ -292,102 +296,110 @@ Todo *CalendarLocal::todo( QString syncProf, QString id )
292} 296}
293void CalendarLocal::removeSyncInfo( QString syncProfile) 297void CalendarLocal::removeSyncInfo( QString syncProfile)
294{ 298{
295 QPtrList<Incidence> all = rawIncidences() ; 299 QPtrList<Incidence> all = rawIncidences() ;
296 Incidence *inc; 300 Incidence *inc;
297 for ( inc = all.first(); inc; inc = all.next() ) { 301 for ( inc = all.first(); inc; inc = all.next() ) {
298 inc->removeID( syncProfile ); 302 inc->removeID( syncProfile );
299 } 303 }
300 if ( syncProfile.isEmpty() ) { 304 if ( syncProfile.isEmpty() ) {
301 QPtrList<Event> el; 305 QPtrList<Event> el;
302 Event *todo; 306 Event *todo;
303 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 307 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
304 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 308 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
305 el.append( todo ); 309 el.append( todo );
306 } 310 }
307 for ( todo = el.first(); todo; todo = el.next() ) { 311 for ( todo = el.first(); todo; todo = el.next() ) {
308 deleteIncidence ( todo ); 312 deleteIncidence ( todo );
309 } 313 }
310 } else { 314 } else {
311 Event *lse = event( "last-syncEvent-"+ syncProfile); 315 Event *lse = event( "last-syncEvent-"+ syncProfile);
312 if ( lse ) 316 if ( lse )
313 deleteIncidence ( lse ); 317 deleteIncidence ( lse );
314 } 318 }
315} 319}
316QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 320QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
317{ 321{
318 QPtrList<Event> el; 322 QPtrList<Event> el;
319 Event *todo; 323 Event *todo;
320 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 324 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
321 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 325 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
322 if ( todo->summary().left(3) == "E: " ) 326 if ( todo->summary().left(3) == "E: " )
323 el.append( todo ); 327 el.append( todo );
324 } 328 }
325 329
326 return el; 330 return el;
327 331
328} 332}
329Event *CalendarLocal::event( QString syncProf, QString id ) 333Event *CalendarLocal::event( QString syncProf, QString id )
330{ 334{
331 Event *todo; 335 Event *todo;
332 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 336 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
333 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 337 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
334 } 338 }
335 339
336 return 0; 340 return 0;
337} 341}
338Todo *CalendarLocal::todo( const QString &uid ) 342Todo *CalendarLocal::todo( const QString &uid )
339{ 343{
340 Todo *todo; 344 Todo *todo;;
345 Todo *retVal = 0;
341 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 346 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
342 if ( todo->calEnabled() && todo->uid() == uid ) return todo; 347 if ( todo->calEnabled() && todo->uid() == uid ) {
348 if ( retVal ) {
349 if ( retVal->calID() > todo->calID() ) {
350 retVal = todo;
351 }
352 } else {
353 retVal = todo;
354 }
355 }
343 } 356 }
344 357 return retVal;
345 return 0;
346} 358}
347QString CalendarLocal::nextSummary() const 359QString CalendarLocal::nextSummary() const
348{ 360{
349 return mNextSummary; 361 return mNextSummary;
350} 362}
351QDateTime CalendarLocal::nextAlarmEventDateTime() const 363QDateTime CalendarLocal::nextAlarmEventDateTime() const
352{ 364{
353 return mNextAlarmEventDateTime; 365 return mNextAlarmEventDateTime;
354} 366}
355void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) 367void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted)
356{ 368{
357 //mNextAlarmIncidence 369 //mNextAlarmIncidence
358 //mNextAlarmDateTime 370 //mNextAlarmDateTime
359 //return mNextSummary; 371 //return mNextSummary;
360 //return mNextAlarmEventDateTime; 372 //return mNextAlarmEventDateTime;
361 bool newNextAlarm = false; 373 bool newNextAlarm = false;
362 bool computeNextAlarm = false; 374 bool computeNextAlarm = false;
363 bool ok; 375 bool ok;
364 int offset; 376 int offset;
365 QDateTime nextA; 377 QDateTime nextA;
366 // QString nextSum; 378 // QString nextSum;
367 //QDateTime nextEvent; 379 //QDateTime nextEvent;
368 if ( mNextAlarmIncidence == 0 || incidence == 0 ) { 380 if ( mNextAlarmIncidence == 0 || incidence == 0 ) {
369 computeNextAlarm = true; 381 computeNextAlarm = true;
370 } else { 382 } else {
371 if ( ! deleted ) { 383 if ( ! deleted ) {
372 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 384 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
373 if ( ok ) { 385 if ( ok ) {
374 if ( nextA < mNextAlarmDateTime ) { 386 if ( nextA < mNextAlarmDateTime ) {
375 deRegisterAlarm(); 387 deRegisterAlarm();
376 mNextAlarmDateTime = nextA; 388 mNextAlarmDateTime = nextA;
377 mNextSummary = incidence->summary(); 389 mNextSummary = incidence->summary();
378 mNextAlarmEventDateTime = nextA.addSecs(offset ) ; 390 mNextAlarmEventDateTime = nextA.addSecs(offset ) ;
379 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 391 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
380 newNextAlarm = true; 392 newNextAlarm = true;
381 mNextAlarmIncidence = incidence; 393 mNextAlarmIncidence = incidence;
382 } else { 394 } else {
383 if ( incidence == mNextAlarmIncidence ) { 395 if ( incidence == mNextAlarmIncidence ) {
384 computeNextAlarm = true; 396 computeNextAlarm = true;
385 } 397 }
386 } 398 }
387 } else { 399 } else {
388 if ( mNextAlarmIncidence == incidence ) { 400 if ( mNextAlarmIncidence == incidence ) {
389 computeNextAlarm = true; 401 computeNextAlarm = true;
390 } 402 }
391 } 403 }
392 } else { // deleted 404 } else { // deleted
393 if ( incidence == mNextAlarmIncidence ) { 405 if ( incidence == mNextAlarmIncidence ) {
@@ -741,101 +753,108 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
741QPtrList<Event> CalendarLocal::rawEvents() 753QPtrList<Event> CalendarLocal::rawEvents()
742{ 754{
743 QPtrList<Event> el; 755 QPtrList<Event> el;
744 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 756 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
745 if ( it->calEnabled() ) el.append( it ); 757 if ( it->calEnabled() ) el.append( it );
746 return el; 758 return el;
747} 759}
748 760
749bool CalendarLocal::addJournal(Journal *journal) 761bool CalendarLocal::addJournal(Journal *journal)
750{ 762{
751 if ( journal->dtStart().isValid()) 763 if ( journal->dtStart().isValid())
752 kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; 764 kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl;
753 else 765 else
754 kdDebug(5800) << "Adding Journal without a DTSTART" << endl; 766 kdDebug(5800) << "Adding Journal without a DTSTART" << endl;
755 767
756 mJournalList.append(journal); 768 mJournalList.append(journal);
757 769
758 journal->registerObserver( this ); 770 journal->registerObserver( this );
759 771
760 setModified( true ); 772 setModified( true );
761 journal->setCalID( mDefaultCalendar ); 773 journal->setCalID( mDefaultCalendar );
762 journal->setCalEnabled( true ); 774 journal->setCalEnabled( true );
763 return true; 775 return true;
764} 776}
765 777
766void CalendarLocal::deleteJournal( Journal *journal ) 778void CalendarLocal::deleteJournal( Journal *journal )
767{ 779{
768 if ( mUndoIncidence ) delete mUndoIncidence; 780 if ( mUndoIncidence ) delete mUndoIncidence;
769 mUndoIncidence = journal->clone(); 781 mUndoIncidence = journal->clone();
770 mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); 782 mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
771 if ( mJournalList.removeRef(journal) ) { 783 if ( mJournalList.removeRef(journal) ) {
772 setModified( true ); 784 setModified( true );
773 } 785 }
774} 786}
775 787
776Journal *CalendarLocal::journal( const QDate &date ) 788Journal *CalendarLocal::journal( const QDate &date )
777{ 789{
778// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; 790// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
779 791
780 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 792 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
781 if ( it->calEnabled() && it->dtStart().date() == date ) 793 if ( it->calEnabled() && it->dtStart().date() == date )
782 return it; 794 return it;
783 795
784 return 0; 796 return 0;
785} 797}
786 798
787Journal *CalendarLocal::journal( const QString &uid ) 799Journal *CalendarLocal::journal( const QString &uid )
788{ 800{
789 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 801 Journal * retVal = 0;
790 if ( it->calEnabled() && it->uid() == uid ) 802 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
791 return it; 803 if ( it->calEnabled() && it->uid() == uid ) {
792 804 if ( retVal ) {
793 return 0; 805 if ( retVal->calID() > it->calID() ) {
806 retVal = it;
807 }
808 } else {
809 retVal = it;
810 }
811 }
812 return retVal;
794} 813}
795 814
796QPtrList<Journal> CalendarLocal::journals() 815QPtrList<Journal> CalendarLocal::journals()
797{ 816{
798 QPtrList<Journal> el; 817 QPtrList<Journal> el;
799 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 818 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
800 if ( it->calEnabled() ) el.append( it ); 819 if ( it->calEnabled() ) el.append( it );
801 return el; 820 return el;
802} 821}
803void CalendarLocal::setCalendarRemove( int id ) 822void CalendarLocal::setCalendarRemove( int id )
804{ 823{
805 824
806 { 825 {
807 QPtrList<Event> EventList = mEventList; 826 QPtrList<Event> EventList = mEventList;
808 Event * ev = EventList.first(); 827 Event * ev = EventList.first();
809 while ( ev ) { 828 while ( ev ) {
810 if ( ev->calID() == id ) 829 if ( ev->calID() == id )
811 deleteEvent( ev ); 830 deleteEvent( ev );
812 ev = EventList.next(); 831 ev = EventList.next();
813 } 832 }
814 } 833 }
815 { 834 {
816 835
817 QPtrList<Todo> TodoList = mTodoList; 836 QPtrList<Todo> TodoList = mTodoList;
818 Todo * ev = TodoList.first(); 837 Todo * ev = TodoList.first();
819 while ( ev ) { 838 while ( ev ) {
820 if ( ev->calID() == id ) 839 if ( ev->calID() == id )
821 deleteTodo( ev ); 840 deleteTodo( ev );
822 ev = TodoList.next(); 841 ev = TodoList.next();
823 } 842 }
824 } 843 }
825 { 844 {
826 QPtrList<Journal> JournalList = mJournalList; 845 QPtrList<Journal> JournalList = mJournalList;
827 Journal * ev = JournalList.first(); 846 Journal * ev = JournalList.first();
828 while ( ev ) { 847 while ( ev ) {
829 if ( ev->calID() == id ) 848 if ( ev->calID() == id )
830 deleteJournal( ev ); 849 deleteJournal( ev );
831 ev = JournalList.next(); 850 ev = JournalList.next();
832 } 851 }
833 } 852 }
834 853
835 if ( mUndoIncidence ) delete mUndoIncidence; 854 if ( mUndoIncidence ) delete mUndoIncidence;
836 mUndoIncidence = 0; 855 mUndoIncidence = 0;
837 856
838} 857}
839 858
840void CalendarLocal::setCalendarEnabled( int id, bool enable ) 859void CalendarLocal::setCalendarEnabled( int id, bool enable )
841{ 860{
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index 3510c7d..72f70c2 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -117,105 +117,105 @@ bool CalFilter::filterTodo(Todo *todo)
117 return false; 117 return false;
118 if (mCriteria & HideCompleted) { 118 if (mCriteria & HideCompleted) {
119 if (todo->isCompleted()) return false; 119 if (todo->isCompleted()) return false;
120 } 120 }
121 121
122 return filterIncidence(todo); 122 return filterIncidence(todo);
123} 123}
124bool CalFilter::showCategories() 124bool CalFilter::showCategories()
125{ 125{
126 return mCriteria & ShowCategories; 126 return mCriteria & ShowCategories;
127} 127}
128int CalFilter::getSecrecy() 128int CalFilter::getSecrecy()
129{ 129{
130 if ( (mCriteria & ShowPublic )) 130 if ( (mCriteria & ShowPublic ))
131 return Incidence::SecrecyPublic; 131 return Incidence::SecrecyPublic;
132 if ( (mCriteria & ShowPrivate )) 132 if ( (mCriteria & ShowPrivate ))
133 return Incidence::SecrecyPrivate; 133 return Incidence::SecrecyPrivate;
134 if ( (mCriteria & ShowConfidential )) 134 if ( (mCriteria & ShowConfidential ))
135 return Incidence::SecrecyConfidential; 135 return Incidence::SecrecyConfidential;
136 return Incidence::SecrecyPublic; 136 return Incidence::SecrecyPublic;
137} 137}
138bool CalFilter::filterIncidence(Incidence *incidence) 138bool CalFilter::filterIncidence(Incidence *incidence)
139{ 139{
140 if ( mCriteria > 7 ) { 140 if ( mCriteria > 7 ) {
141 switch (incidence->secrecy()) { 141 switch (incidence->secrecy()) {
142 case Incidence::SecrecyPublic: 142 case Incidence::SecrecyPublic:
143 if (! (mCriteria & ShowPublic )) 143 if (! (mCriteria & ShowPublic ))
144 return false; 144 return false;
145 break; 145 break;
146 case Incidence::SecrecyPrivate: 146 case Incidence::SecrecyPrivate:
147 if (! (mCriteria & ShowPrivate )) 147 if (! (mCriteria & ShowPrivate ))
148 return false; 148 return false;
149 break; 149 break;
150 case Incidence::SecrecyConfidential: 150 case Incidence::SecrecyConfidential:
151 if (! (mCriteria & ShowConfidential )) 151 if (! (mCriteria & ShowConfidential ))
152 return false; 152 return false;
153 break; 153 break;
154 default: 154 default:
155 return false; 155 return false;
156 break; 156 break;
157 } 157 }
158 } 158 }
159 159
160 // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; 160 // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl;
161 161
162 if (mCriteria & ShowCategories) { 162 if (mCriteria & ShowCategories) {
163 for (QStringList::Iterator it = mCategoryList.begin(); 163 for (QStringList::Iterator it = mCategoryList.begin();
164 it != mCategoryList.end(); ++it ) { 164 it != mCategoryList.end(); ++it ) {
165 QStringList incidenceCategories = incidence->categories(); 165 //QStringList incidenceCategories = incidence->categories();
166 for (QStringList::Iterator it2 = incidenceCategories.begin(); 166 for (QStringList::Iterator it2 = incidence->categoriesP()->begin();
167 it2 != incidenceCategories.end(); ++it2 ) { 167 it2 != incidence->categoriesP()->end(); ++it2 ) {
168 if ((*it) == (*it2)) { 168 if ((*it) == (*it2)) {
169 return true; 169 return true;
170 } 170 }
171 } 171 }
172 } 172 }
173 return false; 173 return false;
174 } else { 174 } else {
175 for (QStringList::Iterator it = mCategoryList.begin(); 175 for (QStringList::Iterator it = mCategoryList.begin();
176 it != mCategoryList.end(); ++it ) { 176 it != mCategoryList.end(); ++it ) {
177 QStringList incidenceCategories = incidence->categories(); 177 //QStringList incidenceCategories = incidence->categories();
178 for (QStringList::Iterator it2 = incidenceCategories.begin(); 178 for (QStringList::Iterator it2 = incidence->categoriesP()->begin();
179 it2 != incidenceCategories.end(); ++it2 ) { 179 it2 != incidence->categoriesP()->end(); ++it2 ) {
180 if ((*it) == (*it2)) { 180 if ((*it) == (*it2)) {
181 return false; 181 return false;
182 } 182 }
183 } 183 }
184 } 184 }
185 return true; 185 return true;
186 } 186 }
187 187
188// kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl; 188// kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl;
189 189
190 return true; 190 return true;
191} 191}
192 192
193void CalFilter::setEnabled(bool enabled) 193void CalFilter::setEnabled(bool enabled)
194{ 194{
195 mEnabled = enabled; 195 mEnabled = enabled;
196} 196}
197 197
198bool CalFilter::isEnabled() 198bool CalFilter::isEnabled()
199{ 199{
200 return mEnabled; 200 return mEnabled;
201} 201}
202 202
203void CalFilter::setCriteria(int criteria) 203void CalFilter::setCriteria(int criteria)
204{ 204{
205 mCriteria = criteria; 205 mCriteria = criteria;
206} 206}
207 207
208int CalFilter::criteria() 208int CalFilter::criteria()
209{ 209{
210 return mCriteria; 210 return mCriteria;
211} 211}
212 212
213void CalFilter::setCategoryList(const QStringList &categoryList) 213void CalFilter::setCategoryList(const QStringList &categoryList)
214{ 214{
215 mCategoryList = categoryList; 215 mCategoryList = categoryList;
216} 216}
217 217
218QStringList CalFilter::categoryList() 218QStringList CalFilter::categoryList()
219{ 219{
220 return mCategoryList; 220 return mCategoryList;
221} 221}
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 4382416..11f7ecc 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -351,96 +351,101 @@ void Incidence::addCategories(const QStringList &categories, bool addToRelations
351 int i; 351 int i;
352 for( i = 0; i < categories.count(); ++i ) { 352 for( i = 0; i < categories.count(); ++i ) {
353 if ( !mCategories.contains (categories[i])) 353 if ( !mCategories.contains (categories[i]))
354 mCategories.append( categories[i] ); 354 mCategories.append( categories[i] );
355 } 355 }
356 checkCategories(); 356 checkCategories();
357 updated(); 357 updated();
358 if ( addToRelations ) { 358 if ( addToRelations ) {
359 Incidence * inc; 359 Incidence * inc;
360 QPtrList<Incidence> Relations = relations(); 360 QPtrList<Incidence> Relations = relations();
361 for (inc=Relations.first();inc;inc=Relations.next()) { 361 for (inc=Relations.first();inc;inc=Relations.next()) {
362 inc->addCategories( categories, true ); 362 inc->addCategories( categories, true );
363 } 363 }
364 } 364 }
365} 365}
366 366
367void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 367void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false
368{ 368{
369 if (mReadOnly) return; 369 if (mReadOnly) return;
370 mCategories = categories; 370 mCategories = categories;
371 checkCategories(); 371 checkCategories();
372 updated(); 372 updated();
373 if ( setForRelations ) { 373 if ( setForRelations ) {
374 Incidence * inc; 374 Incidence * inc;
375 QPtrList<Incidence> Relations = relations(); 375 QPtrList<Incidence> Relations = relations();
376 for (inc=Relations.first();inc;inc=Relations.next()) { 376 for (inc=Relations.first();inc;inc=Relations.next()) {
377 inc->setCategories( categories, true ); 377 inc->setCategories( categories, true );
378 } 378 }
379 } 379 }
380} 380}
381 381
382// TODO: remove setCategories(QString) function 382// TODO: remove setCategories(QString) function
383void Incidence::setCategories(const QString &catStr) 383void Incidence::setCategories(const QString &catStr)
384{ 384{
385 if (mReadOnly) return; 385 if (mReadOnly) return;
386 mCategories.clear(); 386 mCategories.clear();
387 387
388 if (catStr.isEmpty()) return; 388 if (catStr.isEmpty()) return;
389 389
390 mCategories = QStringList::split(",",catStr); 390 mCategories = QStringList::split(",",catStr);
391 391
392 QStringList::Iterator it; 392 QStringList::Iterator it;
393 for(it = mCategories.begin();it != mCategories.end(); ++it) { 393 for(it = mCategories.begin();it != mCategories.end(); ++it) {
394 *it = (*it).stripWhiteSpace(); 394 *it = (*it).stripWhiteSpace();
395 } 395 }
396 checkCategories(); 396 checkCategories();
397 updated(); 397 updated();
398} 398}
399// using this makes filtering 3 times faster
400QStringList* Incidence::categoriesP()
401{
402 return &mCategories;
403}
399 404
400QStringList Incidence::categories() const 405QStringList Incidence::categories() const
401{ 406{
402 return mCategories; 407 return mCategories;
403} 408}
404 409
405QString Incidence::categoriesStr() 410QString Incidence::categoriesStr()
406{ 411{
407 return mCategories.join(","); 412 return mCategories.join(",");
408} 413}
409QString Incidence::categoriesStrWithSpace() 414QString Incidence::categoriesStrWithSpace()
410{ 415{
411 return mCategories.join(", "); 416 return mCategories.join(", ");
412} 417}
413 418
414void Incidence::setRelatedToUid(const QString &relatedToUid) 419void Incidence::setRelatedToUid(const QString &relatedToUid)
415{ 420{
416 if (mReadOnly) return; 421 if (mReadOnly) return;
417 mRelatedToUid = relatedToUid; 422 mRelatedToUid = relatedToUid;
418} 423}
419 424
420QString Incidence::relatedToUid() const 425QString Incidence::relatedToUid() const
421{ 426{
422 return mRelatedToUid; 427 return mRelatedToUid;
423} 428}
424 429
425void Incidence::setRelatedTo(Incidence *relatedTo) 430void Incidence::setRelatedTo(Incidence *relatedTo)
426{ 431{
427 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 432 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
428 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 433 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
429 if (mReadOnly || mRelatedTo == relatedTo) return; 434 if (mReadOnly || mRelatedTo == relatedTo) return;
430 if(mRelatedTo) { 435 if(mRelatedTo) {
431 // updated(); 436 // updated();
432 mRelatedTo->removeRelation(this); 437 mRelatedTo->removeRelation(this);
433 } 438 }
434 mRelatedTo = relatedTo; 439 mRelatedTo = relatedTo;
435 if (mRelatedTo) { 440 if (mRelatedTo) {
436 mRelatedTo->addRelation(this); 441 mRelatedTo->addRelation(this);
437 mRelatedToUid = mRelatedTo->uid(); 442 mRelatedToUid = mRelatedTo->uid();
438 } else { 443 } else {
439 mRelatedToUid = ""; 444 mRelatedToUid = "";
440 } 445 }
441} 446}
442 447
443Incidence *Incidence::relatedTo() const 448Incidence *Incidence::relatedTo() const
444{ 449{
445 return mRelatedTo; 450 return mRelatedTo;
446} 451}
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index fc97ce9..c88ba2f 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -112,96 +112,97 @@ class Incidence : public IncidenceBase
112 virtual bool accept(Visitor &) { return false; } 112 virtual bool accept(Visitor &) { return false; }
113 113
114 virtual Incidence *clone() = 0; 114 virtual Incidence *clone() = 0;
115 virtual void cloneRelations( Incidence * ); 115 virtual void cloneRelations( Incidence * );
116 void addRelationsToList(QPtrList<Incidence> *rel); 116 void addRelationsToList(QPtrList<Incidence> *rel);
117 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; 117 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0;
118 void setReadOnly( bool ); 118 void setReadOnly( bool );
119 119
120 /** 120 /**
121 Recreate event. The event is made a new unique event, but already stored 121 Recreate event. The event is made a new unique event, but already stored
122 event information is preserved. Sets uniquie id, creation date, last 122 event information is preserved. Sets uniquie id, creation date, last
123 modification date and revision number. 123 modification date and revision number.
124 */ 124 */
125 void recreate(); 125 void recreate();
126 Incidence* recreateCloneException(QDate); 126 Incidence* recreateCloneException(QDate);
127 127
128 /** set creation date */ 128 /** set creation date */
129 void setCreated(QDateTime); 129 void setCreated(QDateTime);
130 /** return time and date of creation. */ 130 /** return time and date of creation. */
131 QDateTime created() const; 131 QDateTime created() const;
132 132
133 /** set the number of revisions this event has seen */ 133 /** set the number of revisions this event has seen */
134 void setRevision(int rev); 134 void setRevision(int rev);
135 /** return the number of revisions this event has seen */ 135 /** return the number of revisions this event has seen */
136 int revision() const; 136 int revision() const;
137 137
138 /** Set starting date/time. */ 138 /** Set starting date/time. */
139 virtual void setDtStart(const QDateTime &dtStart); 139 virtual void setDtStart(const QDateTime &dtStart);
140 /** Return the incidence's ending date/time as a QDateTime. */ 140 /** Return the incidence's ending date/time as a QDateTime. */
141 virtual QDateTime dtEnd() const { return QDateTime(); } 141 virtual QDateTime dtEnd() const { return QDateTime(); }
142 142
143 /** sets the event's lengthy description. */ 143 /** sets the event's lengthy description. */
144 void setDescription(const QString &description); 144 void setDescription(const QString &description);
145 /** returns a reference to the event's description. */ 145 /** returns a reference to the event's description. */
146 QString description() const; 146 QString description() const;
147 147
148 /** sets the event's short summary. */ 148 /** sets the event's short summary. */
149 void setSummary(const QString &summary); 149 void setSummary(const QString &summary);
150 /** returns a reference to the event's summary. */ 150 /** returns a reference to the event's summary. */
151 QString summary() const; 151 QString summary() const;
152 152
153 /** set event's applicable categories */ 153 /** set event's applicable categories */
154 void setCategories(const QStringList &categories, bool setForRelations = false); 154 void setCategories(const QStringList &categories, bool setForRelations = false);
155 void addCategories(const QStringList &categories, bool addToRelations = false); 155 void addCategories(const QStringList &categories, bool addToRelations = false);
156 /** set event's categories based on a comma delimited string */ 156 /** set event's categories based on a comma delimited string */
157 void setCategories(const QString &catStr); 157 void setCategories(const QString &catStr);
158 /** return categories in a list */ 158 /** return categories in a list */
159 QStringList categories() const; 159 QStringList categories() const;
160 QStringList* categoriesP();
160 /** return categories as a comma separated string */ 161 /** return categories as a comma separated string */
161 QString categoriesStr(); 162 QString categoriesStr();
162 QString categoriesStrWithSpace(); 163 QString categoriesStrWithSpace();
163 164
164 /** point at some other event to which the event relates. This function should 165 /** point at some other event to which the event relates. This function should
165 * only be used when constructing a calendar before the related Event 166 * only be used when constructing a calendar before the related Event
166 * exists. */ 167 * exists. */
167 void setRelatedToUid(const QString &); 168 void setRelatedToUid(const QString &);
168 /** what event does this one relate to? This function should 169 /** what event does this one relate to? This function should
169 * only be used when constructing a calendar before the related Event 170 * only be used when constructing a calendar before the related Event
170 * exists. */ 171 * exists. */
171 QString relatedToUid() const; 172 QString relatedToUid() const;
172 /** point at some other event to which the event relates */ 173 /** point at some other event to which the event relates */
173 void setRelatedTo(Incidence *relatedTo); 174 void setRelatedTo(Incidence *relatedTo);
174 /** what event does this one relate to? */ 175 /** what event does this one relate to? */
175 Incidence *relatedTo() const; 176 Incidence *relatedTo() const;
176 /** All events that are related to this event */ 177 /** All events that are related to this event */
177 QPtrList<Incidence> relations() const; 178 QPtrList<Incidence> relations() const;
178 /** Add an event which is related to this event */ 179 /** Add an event which is related to this event */
179 void addRelation(Incidence *); 180 void addRelation(Incidence *);
180 /** Remove event that is related to this event */ 181 /** Remove event that is related to this event */
181 void removeRelation(Incidence *); 182 void removeRelation(Incidence *);
182 183
183 /** returns the list of dates which are exceptions to the recurrence rule */ 184 /** returns the list of dates which are exceptions to the recurrence rule */
184 DateList exDates() const; 185 DateList exDates() const;
185 /** sets the list of dates which are exceptions to the recurrence rule */ 186 /** sets the list of dates which are exceptions to the recurrence rule */
186 void setExDates(const DateList &_exDates); 187 void setExDates(const DateList &_exDates);
187 void setExDates(const char *dates); 188 void setExDates(const char *dates);
188 /** Add a date to the list of exceptions of the recurrence rule. */ 189 /** Add a date to the list of exceptions of the recurrence rule. */
189 void addExDate(const QDate &date); 190 void addExDate(const QDate &date);
190 191
191 /** returns true if there is an exception for this date in the recurrence 192 /** returns true if there is an exception for this date in the recurrence
192 rule set, or false otherwise. */ 193 rule set, or false otherwise. */
193 bool isException(const QDate &qd) const; 194 bool isException(const QDate &qd) const;
194 195
195 /** add attachment to this event */ 196 /** add attachment to this event */
196 void addAttachment(Attachment *attachment); 197 void addAttachment(Attachment *attachment);
197 /** remove and delete a specific attachment */ 198 /** remove and delete a specific attachment */
198 void deleteAttachment(Attachment *attachment); 199 void deleteAttachment(Attachment *attachment);
199 /** remove and delete all attachments with this mime type */ 200 /** remove and delete all attachments with this mime type */
200 void deleteAttachments(const QString& mime); 201 void deleteAttachments(const QString& mime);
201 /** return list of all associated attachments */ 202 /** return list of all associated attachments */
202 QPtrList<Attachment> attachments() const; 203 QPtrList<Attachment> attachments() const;
203 /** find a list of attachments with this mime type */ 204 /** find a list of attachments with this mime type */
204 QPtrList<Attachment> attachments(const QString& mime) const; 205 QPtrList<Attachment> attachments(const QString& mime) const;
205 206
206 /** sets the event's status the value specified. See the enumeration 207 /** sets the event's status the value specified. See the enumeration
207 * above for possible values. */ 208 * above for possible values. */