summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (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
@@ -204,58 +204,62 @@ bool 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 );
@@ -316,54 +320,62 @@ void CalendarLocal::removeSyncInfo( QString syncProfile)
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;
@@ -765,53 +777,60 @@ bool CalendarLocal::addJournal(Journal *journal)
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;
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index 3510c7d..72f70c2 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -141,63 +141,63 @@ bool CalFilter::filterIncidence(Incidence *incidence)
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)
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 4382416..11f7ecc 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -375,48 +375,53 @@ void Incidence::setCategories(const QStringList &categories, bool setForRelation
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;
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index fc97ce9..c88ba2f 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -136,48 +136,49 @@ class Incidence : public IncidenceBase
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 */