author | zautrix <zautrix> | 2004-12-07 09:55:57 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-07 09:55:57 (UTC) |
commit | 17b25691f0332e648dd1d800e89ccf4e1da8955d (patch) (unidiff) | |
tree | b7bc28e6c57c043fc49328a7ebd86e1b5cd0f17a /libkcal/calendarlocal.cpp | |
parent | dcd2bbbc8d3064b35f268a831c567feaafea5fd8 (diff) | |
download | kdepimpi-17b25691f0332e648dd1d800e89ccf4e1da8955d.zip kdepimpi-17b25691f0332e648dd1d800e89ccf4e1da8955d.tar.gz kdepimpi-17b25691f0332e648dd1d800e89ccf4e1da8955d.tar.bz2 |
some kopi usebility fixes
-rw-r--r-- | libkcal/calendarlocal.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 3f46d53..12294c0 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -131,98 +131,100 @@ bool CalendarLocal::addEventNoDup( Event *event ) | |||
131 | { | 131 | { |
132 | Event * eve; | 132 | Event * eve; |
133 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 133 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
134 | if ( *eve == *event ) { | 134 | if ( *eve == *event ) { |
135 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 135 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
136 | return false; | 136 | return false; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | return addEvent( event ); | 139 | return addEvent( event ); |
140 | } | 140 | } |
141 | 141 | ||
142 | bool CalendarLocal::addEvent( Event *event ) | 142 | bool CalendarLocal::addEvent( Event *event ) |
143 | { | 143 | { |
144 | insertEvent( event ); | 144 | insertEvent( event ); |
145 | 145 | ||
146 | event->registerObserver( this ); | 146 | event->registerObserver( this ); |
147 | 147 | ||
148 | setModified( true ); | 148 | setModified( true ); |
149 | 149 | ||
150 | return true; | 150 | return true; |
151 | } | 151 | } |
152 | 152 | ||
153 | void CalendarLocal::deleteEvent( Event *event ) | 153 | void CalendarLocal::deleteEvent( Event *event ) |
154 | { | 154 | { |
155 | 155 | if ( mUndoIncidence ) delete mUndoIncidence; | |
156 | 156 | mUndoIncidence = event->clone(); | |
157 | if ( mEventList.removeRef( event ) ) { | 157 | if ( mEventList.removeRef( event ) ) { |
158 | setModified( true ); | 158 | setModified( true ); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | Event *CalendarLocal::event( const QString &uid ) | 163 | Event *CalendarLocal::event( const QString &uid ) |
164 | { | 164 | { |
165 | 165 | ||
166 | Event *event; | 166 | Event *event; |
167 | 167 | ||
168 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 168 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
169 | if ( event->uid() == uid ) { | 169 | if ( event->uid() == uid ) { |
170 | return event; | 170 | return event; |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 176 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
177 | { | 177 | { |
178 | Todo * eve; | 178 | Todo * eve; |
179 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 179 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
180 | if ( *eve == *todo ) { | 180 | if ( *eve == *todo ) { |
181 | //qDebug("duplicate todo found! not inserted! "); | 181 | //qDebug("duplicate todo found! not inserted! "); |
182 | return false; | 182 | return false; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | return addTodo( todo ); | 185 | return addTodo( todo ); |
186 | } | 186 | } |
187 | bool CalendarLocal::addTodo( Todo *todo ) | 187 | bool CalendarLocal::addTodo( Todo *todo ) |
188 | { | 188 | { |
189 | mTodoList.append( todo ); | 189 | mTodoList.append( todo ); |
190 | 190 | ||
191 | todo->registerObserver( this ); | 191 | todo->registerObserver( this ); |
192 | 192 | ||
193 | // Set up subtask relations | 193 | // Set up subtask relations |
194 | setupRelations( todo ); | 194 | setupRelations( todo ); |
195 | 195 | ||
196 | setModified( true ); | 196 | setModified( true ); |
197 | 197 | ||
198 | return true; | 198 | return true; |
199 | } | 199 | } |
200 | 200 | ||
201 | void CalendarLocal::deleteTodo( Todo *todo ) | 201 | void CalendarLocal::deleteTodo( Todo *todo ) |
202 | { | 202 | { |
203 | // Handle orphaned children | 203 | // Handle orphaned children |
204 | removeRelations( todo ); | 204 | if ( mUndoIncidence ) delete mUndoIncidence; |
205 | mUndoIncidence = todo->clone(); | ||
206 | removeRelations( todo ); | ||
205 | 207 | ||
206 | if ( mTodoList.removeRef( todo ) ) { | 208 | if ( mTodoList.removeRef( todo ) ) { |
207 | setModified( true ); | 209 | setModified( true ); |
208 | } | 210 | } |
209 | } | 211 | } |
210 | 212 | ||
211 | QPtrList<Todo> CalendarLocal::rawTodos() | 213 | QPtrList<Todo> CalendarLocal::rawTodos() |
212 | { | 214 | { |
213 | return mTodoList; | 215 | return mTodoList; |
214 | } | 216 | } |
215 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 217 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
216 | { | 218 | { |
217 | Todo *todo; | 219 | Todo *todo; |
218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 220 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
219 | if ( todo->getID( syncProf ) == id ) return todo; | 221 | if ( todo->getID( syncProf ) == id ) return todo; |
220 | } | 222 | } |
221 | 223 | ||
222 | return 0; | 224 | return 0; |
223 | } | 225 | } |
224 | void CalendarLocal::removeSyncInfo( QString syncProfile) | 226 | void CalendarLocal::removeSyncInfo( QString syncProfile) |
225 | { | 227 | { |
226 | QPtrList<Incidence> all = rawIncidences() ; | 228 | QPtrList<Incidence> all = rawIncidences() ; |
227 | Incidence *inc; | 229 | Incidence *inc; |
228 | for ( inc = all.first(); inc; inc = all.next() ) { | 230 | for ( inc = all.first(); inc; inc = all.next() ) { |
@@ -666,48 +668,51 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | |||
666 | 668 | ||
667 | QPtrList<Event> CalendarLocal::rawEvents() | 669 | QPtrList<Event> CalendarLocal::rawEvents() |
668 | { | 670 | { |
669 | return mEventList; | 671 | return mEventList; |
670 | } | 672 | } |
671 | 673 | ||
672 | bool CalendarLocal::addJournal(Journal *journal) | 674 | bool CalendarLocal::addJournal(Journal *journal) |
673 | { | 675 | { |
674 | if ( journal->dtStart().isValid()) | 676 | if ( journal->dtStart().isValid()) |
675 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; | 677 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; |
676 | else | 678 | else |
677 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; | 679 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; |
678 | 680 | ||
679 | mJournalList.append(journal); | 681 | mJournalList.append(journal); |
680 | 682 | ||
681 | journal->registerObserver( this ); | 683 | journal->registerObserver( this ); |
682 | 684 | ||
683 | setModified( true ); | 685 | setModified( true ); |
684 | 686 | ||
685 | return true; | 687 | return true; |
686 | } | 688 | } |
687 | 689 | ||
688 | void CalendarLocal::deleteJournal( Journal *journal ) | 690 | void CalendarLocal::deleteJournal( Journal *journal ) |
689 | { | 691 | { |
692 | if ( mUndoIncidence ) delete mUndoIncidence; | ||
693 | mUndoIncidence = journal->clone(); | ||
694 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | ||
690 | if ( mJournalList.removeRef(journal) ) { | 695 | if ( mJournalList.removeRef(journal) ) { |
691 | setModified( true ); | 696 | setModified( true ); |
692 | } | 697 | } |
693 | } | 698 | } |
694 | 699 | ||
695 | Journal *CalendarLocal::journal( const QDate &date ) | 700 | Journal *CalendarLocal::journal( const QDate &date ) |
696 | { | 701 | { |
697 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 702 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
698 | 703 | ||
699 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 704 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
700 | if ( it->dtStart().date() == date ) | 705 | if ( it->dtStart().date() == date ) |
701 | return it; | 706 | return it; |
702 | 707 | ||
703 | return 0; | 708 | return 0; |
704 | } | 709 | } |
705 | 710 | ||
706 | Journal *CalendarLocal::journal( const QString &uid ) | 711 | Journal *CalendarLocal::journal( const QString &uid ) |
707 | { | 712 | { |
708 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 713 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
709 | if ( it->uid() == uid ) | 714 | if ( it->uid() == uid ) |
710 | return it; | 715 | return it; |
711 | 716 | ||
712 | return 0; | 717 | return 0; |
713 | } | 718 | } |