summaryrefslogtreecommitdiffabout
path: root/libkcal/calendar.cpp
authorzautrix <zautrix>2005-07-30 14:43:57 (UTC)
committer zautrix <zautrix>2005-07-30 14:43:57 (UTC)
commit9ca2cd947f22d33543e065f54c6487e86d80befa (patch) (unidiff)
tree549192e9e27e8972e2b48cf40e1599118df12da5 /libkcal/calendar.cpp
parent055928e26613f4ab249bd82be86890ed278372f6 (diff)
downloadkdepimpi-9ca2cd947f22d33543e065f54c6487e86d80befa.zip
kdepimpi-9ca2cd947f22d33543e065f54c6487e86d80befa.tar.gz
kdepimpi-9ca2cd947f22d33543e065f54c6487e86d80befa.tar.bz2
fixxx
Diffstat (limited to 'libkcal/calendar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp42
1 files changed, 38 insertions, 4 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index b7990d4..b1806ee 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -1,243 +1,262 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <stdlib.h> 22#include <stdlib.h>
23#include <time.h> 23#include <time.h>
24 24
25#include <kdebug.h> 25#include <kdebug.h>
26#include <kglobal.h> 26#include <kglobal.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#include "exceptions.h" 29#include "exceptions.h"
30#include "calfilter.h" 30#include "calfilter.h"
31 31
32#include "calendar.h" 32#include "calendar.h"
33#include "syncdefines.h" 33#include "syncdefines.h"
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37Calendar::Calendar() 37Calendar::Calendar()
38{ 38{
39 39
40 init(); 40 init();
41 setTimeZoneId( " 00:00 Europe/London(UTC)" ); 41 setTimeZoneId( " 00:00 Europe/London(UTC)" );
42} 42}
43 43
44Calendar::Calendar( const QString &timeZoneId ) 44Calendar::Calendar( const QString &timeZoneId )
45{ 45{
46 46
47 init(); 47 init();
48 setTimeZoneId(timeZoneId); 48 setTimeZoneId(timeZoneId);
49} 49}
50 50
51void Calendar::init() 51void Calendar::init()
52{ 52{
53 mObserver = 0; 53 mObserver = 0;
54 mNewObserver = false; 54 mNewObserver = false;
55 mUndoIncidence = 0; 55 mUndoIncidence = 0;
56 mDeleteIncidencesOnClose = true; 56 mDeleteIncidencesOnClose = true;
57 mModified = false; 57 mModified = false;
58 mDefaultCalendar = 1; 58 mDefaultCalendar = 1;
59 // Setup default filter, which does nothing 59 // Setup default filter, which does nothing
60 mDefaultFilter = new CalFilter; 60 mDefaultFilter = new CalFilter;
61 mFilter = mDefaultFilter; 61 mFilter = mDefaultFilter;
62 mFilter->setEnabled(false); 62 mFilter->setEnabled(false);
63 63
64 // initialize random numbers. This is a hack, and not 64 // initialize random numbers. This is a hack, and not
65 // even that good of one at that. 65 // even that good of one at that.
66// srandom(time(0)); 66// srandom(time(0));
67 67
68 // user information... 68 // user information...
69 setOwner(i18n("Unknown Name")); 69 setOwner(i18n("Unknown Name"));
70 setEmail(i18n("unknown@nowhere")); 70 setEmail(i18n("unknown@nowhere"));
71 71
72#if 0 72#if 0
73 tmpStr = KOPrefs::instance()->mTimeZone; 73 tmpStr = KOPrefs::instance()->mTimeZone;
74// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; 74// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl;
75 int dstSetting = KOPrefs::instance()->mDaylightSavings; 75 int dstSetting = KOPrefs::instance()->mDaylightSavings;
76 extern long int timezone; 76 extern long int timezone;
77 struct tm *now; 77 struct tm *now;
78 time_t curtime; 78 time_t curtime;
79 curtime = time(0); 79 curtime = time(0);
80 now = localtime(&curtime); 80 now = localtime(&curtime);
81 int hourOff = - ((timezone / 60) / 60); 81 int hourOff = - ((timezone / 60) / 60);
82 if (now->tm_isdst) 82 if (now->tm_isdst)
83 hourOff += 1; 83 hourOff += 1;
84 QString tzStr; 84 QString tzStr;
85 tzStr.sprintf("%.2d%.2d", 85 tzStr.sprintf("%.2d%.2d",
86 hourOff, 86 hourOff,
87 abs((timezone / 60) % 60)); 87 abs((timezone / 60) % 60));
88 88
89 // if no time zone was in the config file, write what we just discovered. 89 // if no time zone was in the config file, write what we just discovered.
90 if (tmpStr.isEmpty()) { 90 if (tmpStr.isEmpty()) {
91// KOPrefs::instance()->mTimeZone = tzStr; 91// KOPrefs::instance()->mTimeZone = tzStr;
92 } else { 92 } else {
93 tzStr = tmpStr; 93 tzStr = tmpStr;
94 } 94 }
95 95
96 // if daylight savings has changed since last load time, we need 96 // if daylight savings has changed since last load time, we need
97 // to rewrite these settings to the config file. 97 // to rewrite these settings to the config file.
98 if ((now->tm_isdst && !dstSetting) || 98 if ((now->tm_isdst && !dstSetting) ||
99 (!now->tm_isdst && dstSetting)) { 99 (!now->tm_isdst && dstSetting)) {
100 KOPrefs::instance()->mTimeZone = tzStr; 100 KOPrefs::instance()->mTimeZone = tzStr;
101 KOPrefs::instance()->mDaylightSavings = now->tm_isdst; 101 KOPrefs::instance()->mDaylightSavings = now->tm_isdst;
102 } 102 }
103 103
104 setTimeZone(tzStr); 104 setTimeZone(tzStr);
105#endif 105#endif
106 106
107// KOPrefs::instance()->writeConfig(); 107// KOPrefs::instance()->writeConfig();
108} 108}
109 109
110Calendar::~Calendar() 110Calendar::~Calendar()
111{ 111{
112 delete mDefaultFilter; 112 delete mDefaultFilter;
113 if ( mUndoIncidence ) 113 clearUndo( 0 );
114 delete mUndoIncidence; 114}
115} 115void Calendar::clearUndo( Incidence * newUndo )
116{
117
118 if ( mUndoIncidence ) {
119 if ( mUndoIncidence->typeID() == eventID )
120 delete ((Event*) mUndoIncidence) ;
121 else if ( mUndoIncidence->typeID() == todoID )
122 delete ( (Todo*) mUndoIncidence );
123 else if ( mUndoIncidence->typeID() == journalID )
124 delete ( (Journal*) mUndoIncidence );
125 else
126 delete mUndoIncidence;
127 }
128 mUndoIncidence = newUndo;
129 if ( mUndoIncidence ) {
130 mUndoIncidence->clearRelations();
131 }
132
133}
134
116void Calendar::setDontDeleteIncidencesOnClose () 135void Calendar::setDontDeleteIncidencesOnClose ()
117{ 136{
118 mDeleteIncidencesOnClose = false; 137 mDeleteIncidencesOnClose = false;
119} 138}
120void Calendar::setDefaultCalendar( int d ) 139void Calendar::setDefaultCalendar( int d )
121{ 140{
122 mDefaultCalendar = d; 141 mDefaultCalendar = d;
123} 142}
124int Calendar::defaultCalendar() 143int Calendar::defaultCalendar()
125{ 144{
126 return mDefaultCalendar; 145 return mDefaultCalendar;
127} 146}
128const QString &Calendar::getOwner() const 147const QString &Calendar::getOwner() const
129{ 148{
130 return mOwner; 149 return mOwner;
131} 150}
132 151
133bool Calendar::undoDeleteIncidence() 152bool Calendar::undoDeleteIncidence()
134{ 153{
135 if (!mUndoIncidence) 154 if (!mUndoIncidence)
136 return false; 155 return false;
137 addIncidence(mUndoIncidence); 156 addIncidence(mUndoIncidence);
138 mUndoIncidence = 0; 157 mUndoIncidence = 0;
139 return true; 158 return true;
140} 159}
141void Calendar::setOwner(const QString &os) 160void Calendar::setOwner(const QString &os)
142{ 161{
143 int i; 162 int i;
144 mOwner = os; 163 mOwner = os;
145 i = mOwner.find(','); 164 i = mOwner.find(',');
146 if (i != -1) 165 if (i != -1)
147 mOwner = mOwner.left(i); 166 mOwner = mOwner.left(i);
148 167
149 setModified( true ); 168 setModified( true );
150} 169}
151 170
152void Calendar::setTimeZone(const QString & tz) 171void Calendar::setTimeZone(const QString & tz)
153{ 172{
154 bool neg = FALSE; 173 bool neg = FALSE;
155 int hours, minutes; 174 int hours, minutes;
156 QString tmpStr(tz); 175 QString tmpStr(tz);
157 176
158 if (tmpStr.left(1) == "-") 177 if (tmpStr.left(1) == "-")
159 neg = TRUE; 178 neg = TRUE;
160 if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") 179 if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+")
161 tmpStr.remove(0, 1); 180 tmpStr.remove(0, 1);
162 hours = tmpStr.left(2).toInt(); 181 hours = tmpStr.left(2).toInt();
163 if (tmpStr.length() > 2) 182 if (tmpStr.length() > 2)
164 minutes = tmpStr.right(2).toInt(); 183 minutes = tmpStr.right(2).toInt();
165 else 184 else
166 minutes = 0; 185 minutes = 0;
167 mTimeZone = (60*hours+minutes); 186 mTimeZone = (60*hours+minutes);
168 if (neg) 187 if (neg)
169 mTimeZone = -mTimeZone; 188 mTimeZone = -mTimeZone;
170 mLocalTime = false; 189 mLocalTime = false;
171 190
172 setModified( true ); 191 setModified( true );
173} 192}
174 193
175QString Calendar::getTimeZoneStr() const 194QString Calendar::getTimeZoneStr() const
176{ 195{
177 if (mLocalTime) 196 if (mLocalTime)
178 return ""; 197 return "";
179 QString tmpStr; 198 QString tmpStr;
180 int hours = abs(mTimeZone / 60); 199 int hours = abs(mTimeZone / 60);
181 int minutes = abs(mTimeZone % 60); 200 int minutes = abs(mTimeZone % 60);
182 bool neg = mTimeZone < 0; 201 bool neg = mTimeZone < 0;
183 202
184 tmpStr.sprintf("%c%.2d%.2d", 203 tmpStr.sprintf("%c%.2d%.2d",
185 (neg ? '-' : '+'), 204 (neg ? '-' : '+'),
186 hours, minutes); 205 hours, minutes);
187 return tmpStr; 206 return tmpStr;
188} 207}
189 208
190void Calendar::setTimeZone(int tz) 209void Calendar::setTimeZone(int tz)
191{ 210{
192 mTimeZone = tz; 211 mTimeZone = tz;
193 mLocalTime = false; 212 mLocalTime = false;
194 213
195 setModified( true ); 214 setModified( true );
196} 215}
197 216
198int Calendar::getTimeZone() const 217int Calendar::getTimeZone() const
199{ 218{
200 return mTimeZone; 219 return mTimeZone;
201} 220}
202 221
203void Calendar::setTimeZoneId(const QString &id) 222void Calendar::setTimeZoneId(const QString &id)
204{ 223{
205 mTimeZoneId = id; 224 mTimeZoneId = id;
206 mLocalTime = false; 225 mLocalTime = false;
207 mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); 226 mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId);
208 if ( mTimeZone > 1000) 227 if ( mTimeZone > 1000)
209 setLocalTime(); 228 setLocalTime();
210 //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); 229 //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone);
211 setModified( true ); 230 setModified( true );
212} 231}
213 232
214QString Calendar::timeZoneId() const 233QString Calendar::timeZoneId() const
215{ 234{
216 return mTimeZoneId; 235 return mTimeZoneId;
217} 236}
218 237
219void Calendar::setLocalTime() 238void Calendar::setLocalTime()
220{ 239{
221 //qDebug("Calendar::setLocalTime() "); 240 //qDebug("Calendar::setLocalTime() ");
222 mLocalTime = true; 241 mLocalTime = true;
223 mTimeZone = 0; 242 mTimeZone = 0;
224 mTimeZoneId = ""; 243 mTimeZoneId = "";
225 244
226 setModified( true ); 245 setModified( true );
227} 246}
228 247
229bool Calendar::isLocalTime() const 248bool Calendar::isLocalTime() const
230{ 249{
231 return mLocalTime; 250 return mLocalTime;
232} 251}
233 252
234const QString &Calendar::getEmail() 253const QString &Calendar::getEmail()
235{ 254{
236 return mOwnerEmail; 255 return mOwnerEmail;
237} 256}
238 257
239void Calendar::setEmail(const QString &e) 258void Calendar::setEmail(const QString &e)
240{ 259{
241 mOwnerEmail = e; 260 mOwnerEmail = e;
242 261
243 setModified( true ); 262 setModified( true );
@@ -322,168 +341,183 @@ QPtrList<Incidence> Calendar::rawIncidences()
322QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 341QPtrList<Event> Calendar::events( const QDate &date, bool sorted )
323{ 342{
324 QPtrList<Event> el = rawEventsForDate(date,sorted); 343 QPtrList<Event> el = rawEventsForDate(date,sorted);
325 mFilter->apply(&el); 344 mFilter->apply(&el);
326 return el; 345 return el;
327} 346}
328 347
329QPtrList<Event> Calendar::events( const QDateTime &qdt ) 348QPtrList<Event> Calendar::events( const QDateTime &qdt )
330{ 349{
331 QPtrList<Event> el = rawEventsForDate(qdt); 350 QPtrList<Event> el = rawEventsForDate(qdt);
332 mFilter->apply(&el); 351 mFilter->apply(&el);
333 return el; 352 return el;
334} 353}
335 354
336QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 355QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
337 bool inclusive) 356 bool inclusive)
338{ 357{
339 QPtrList<Event> el = rawEvents(start,end,inclusive); 358 QPtrList<Event> el = rawEvents(start,end,inclusive);
340 mFilter->apply(&el); 359 mFilter->apply(&el);
341 return el; 360 return el;
342} 361}
343 362
344QPtrList<Event> Calendar::events() 363QPtrList<Event> Calendar::events()
345{ 364{
346 QPtrList<Event> el = rawEvents(); 365 QPtrList<Event> el = rawEvents();
347 mFilter->apply(&el); 366 mFilter->apply(&el);
348 return el; 367 return el;
349} 368}
350void Calendar::addIncidenceBranch(Incidence *i) 369void Calendar::addIncidenceBranch(Incidence *i)
351{ 370{
352 addIncidence( i ); 371 addIncidence( i );
353 Incidence * inc; 372 Incidence * inc;
354 QPtrList<Incidence> Relations = i->relations(); 373 QPtrList<Incidence> Relations = i->relations();
355 for (inc=Relations.first();inc;inc=Relations.next()) { 374 for (inc=Relations.first();inc;inc=Relations.next()) {
356 addIncidenceBranch( inc ); 375 addIncidenceBranch( inc );
357 } 376 }
358} 377}
359 378
360bool Calendar::addIncidence(Incidence *i) 379bool Calendar::addIncidence(Incidence *i)
361{ 380{
362 Incidence::AddVisitor<Calendar> v(this); 381 Incidence::AddVisitor<Calendar> v(this);
363 if ( i->calID() == 0 ) 382 if ( i->calID() == 0 )
364 i->setCalID( mDefaultCalendar ); 383 i->setCalID( mDefaultCalendar );
365 i->setCalEnabled( true ); 384 i->setCalEnabled( true );
366 return i->accept(v); 385 return i->accept(v);
367} 386}
368void Calendar::deleteIncidence(Incidence *in) 387void Calendar::deleteIncidence(Incidence *in)
369{ 388{
370 if ( in->typeID() == eventID ) 389 if ( in->typeID() == eventID )
371 deleteEvent( (Event*) in ); 390 deleteEvent( (Event*) in );
372 else if ( in->typeID() == todoID ) 391 else if ( in->typeID() == todoID )
373 deleteTodo( (Todo*) in); 392 deleteTodo( (Todo*) in);
374 else if ( in->typeID() == journalID ) 393 else if ( in->typeID() == journalID )
375 deleteJournal( (Journal*) in ); 394 deleteJournal( (Journal*) in );
376} 395}
377 396
378Incidence* Calendar::incidence( const QString& uid ) 397Incidence* Calendar::incidence( const QString& uid )
379{ 398{
380 Incidence* i; 399 Incidence* i;
381 400
382 if( (i = todo( uid )) != 0 ) 401 if( (i = todo( uid )) != 0 )
383 return i; 402 return i;
384 if( (i = event( uid )) != 0 ) 403 if( (i = event( uid )) != 0 )
385 return i; 404 return i;
386 if( (i = journal( uid )) != 0 ) 405 if( (i = journal( uid )) != 0 )
387 return i; 406 return i;
388 407
389 return 0; 408 return 0;
390} 409}
391 410
392QPtrList<Todo> Calendar::todos() 411QPtrList<Todo> Calendar::todos()
393{ 412{
394 QPtrList<Todo> tl = rawTodos(); 413 QPtrList<Todo> tl = rawTodos();
395 mFilter->apply( &tl ); 414 mFilter->apply( &tl );
396 return tl; 415 return tl;
397} 416}
398 417
399// When this is called, the todo have already been added to the calendar. 418// When this is called, the todo have already been added to the calendar.
400// This method is only about linking related todos 419// This method is only about linking related todos
401void Calendar::setupRelations( Incidence *incidence ) 420void Calendar::setupRelations( Incidence *incidence )
402{ 421{
403 QString uid = incidence->uid(); 422 QString uid = incidence->uid();
404 //qDebug("Calendar::setupRelations "); 423 //qDebug("Calendar::setupRelations ");
405 // First, go over the list of orphans and see if this is their parent 424 // First, go over the list of orphans and see if this is their parent
406 while( Incidence* i = mOrphans[ uid ] ) { 425 while( Incidence* i = mOrphans[ uid ] ) {
407 mOrphans.remove( uid ); 426 mOrphans.remove( uid );
408 i->setRelatedTo( incidence ); 427 i->setRelatedTo( incidence );
409 incidence->addRelation( i ); 428 incidence->addRelation( i );
410 mOrphanUids.remove( i->uid() ); 429 mOrphanUids.remove( i->uid() );
411 } 430 }
412 431
413 // Now see about this incidences parent 432 // Now see about this incidences parent
414 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { 433 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) {
415 // This incidence has a uid it is related to, but is not registered to it yet 434 // This incidence has a uid it is related to, but is not registered to it yet
416 // Try to find it 435 // Try to find it
417 Incidence* parent = this->incidence( incidence->relatedToUid() ); 436 Incidence* parent = this->incidence( incidence->relatedToUid() );
418 if( parent ) { 437 if( parent ) {
419 // Found it 438 // Found it
420 incidence->setRelatedTo( parent ); 439 incidence->setRelatedTo( parent );
421 parent->addRelation( incidence ); 440 parent->addRelation( incidence );
422 } else { 441 } else {
423 // Not found, put this in the mOrphans list 442 // Not found, put this in the mOrphans list
424 mOrphans.insert( incidence->relatedToUid(), incidence ); 443 mOrphans.insert( incidence->relatedToUid(), incidence );
425 mOrphanUids.insert( incidence->uid(), incidence ); 444 mOrphanUids.insert( incidence->uid(), incidence );
426 } 445 }
427 } 446 }
428} 447}
429 448
430// If a task with subtasks is deleted, move it's subtasks to the orphans list 449// If a task with subtasks is deleted, move it's subtasks to the orphans list
431void Calendar::removeRelations( Incidence *incidence ) 450void Calendar::removeRelations( Incidence *incidence )
432{ 451{
433 // qDebug("Calendar::removeRelations "); 452 // qDebug("Calendar::removeRelations ");
434 QString uid = incidence->uid(); 453 QString uid = incidence->uid();
435 454
436 QPtrList<Incidence> relations = incidence->relations(); 455 QPtrList<Incidence> relations = incidence->relations();
437 for( Incidence* i = relations.first(); i; i = relations.next() ) 456 for( Incidence* i = relations.first(); i; i = relations.next() )
438 if( !mOrphanUids.find( i->uid() ) ) { 457 if( !mOrphanUids.find( i->uid() ) ) {
439 mOrphans.insert( uid, i ); 458 mOrphans.insert( uid, i );
440 mOrphanUids.insert( i->uid(), i ); 459 mOrphanUids.insert( i->uid(), i );
441 i->setRelatedTo( 0 ); 460 i->setRelatedTo( 0 );
442 i->setRelatedToUid( uid ); 461 i->setRelatedToUid( uid );
443 } 462 }
444 463
445 // If this incidence is related to something else, tell that about it 464 // If this incidence is related to something else, tell that about it
446 if( incidence->relatedTo() ) 465 if( incidence->relatedTo() )
447 incidence->relatedTo()->removeRelation( incidence ); 466 incidence->relatedTo()->removeRelation( incidence );
448 467
449 // Remove this one from the orphans list 468 // Remove this one from the orphans list
450 if( mOrphanUids.remove( uid ) ) 469 if( mOrphanUids.remove( uid ) ) {
470 QString r2uid = incidence->relatedToUid();
471 QPtrList<Incidence> tempList;
472 while( Incidence* i = mOrphans[ r2uid ] ) {
473 mOrphans.remove( r2uid );
474 if ( i != incidence ) tempList.append( i );
475 }
476 Incidence* inc = tempList.first();
477 while ( inc ) {
478 mOrphans.insert( r2uid, inc );
479 inc = tempList.next();
480 }
481 }
482 // LR: and another big bad bug found
483#if 0
451 // This incidence is located in the orphans list - it should be removed 484 // This incidence is located in the orphans list - it should be removed
452 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { 485 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
453 // Removing wasn't that easy 486 // Removing wasn't that easy
454 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { 487 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) {
455 if( it.current()->uid() == uid ) { 488 if( it.current()->uid() == uid ) {
456 mOrphans.remove( it.currentKey() ); 489 mOrphans.remove( it.currentKey() );
457 break; 490 break;
458 } 491 }
459 } 492 }
460 } 493 }
494#endif
461} 495}
462 496
463void Calendar::registerObserver( Observer *observer ) 497void Calendar::registerObserver( Observer *observer )
464{ 498{
465 mObserver = observer; 499 mObserver = observer;
466 mNewObserver = true; 500 mNewObserver = true;
467} 501}
468 502
469void Calendar::setModified( bool modified ) 503void Calendar::setModified( bool modified )
470{ 504{
471 if ( mObserver ) mObserver->calendarModified( modified, this ); 505 if ( mObserver ) mObserver->calendarModified( modified, this );
472 if ( modified != mModified || mNewObserver ) { 506 if ( modified != mModified || mNewObserver ) {
473 mNewObserver = false; 507 mNewObserver = false;
474 // if ( mObserver ) mObserver->calendarModified( modified, this ); 508 // if ( mObserver ) mObserver->calendarModified( modified, this );
475 mModified = modified; 509 mModified = modified;
476 } 510 }
477} 511}
478 512
479void Calendar::setLoadedProductId( const QString &id ) 513void Calendar::setLoadedProductId( const QString &id )
480{ 514{
481 mLoadedProductId = id; 515 mLoadedProductId = id;
482} 516}
483 517
484QString Calendar::loadedProductId() 518QString Calendar::loadedProductId()
485{ 519{
486 return mLoadedProductId; 520 return mLoadedProductId;
487} 521}
488 522
489//#include "calendar.moc" 523//#include "calendar.moc"