-rw-r--r-- | libkcal/incidencebase.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 9479048..707d666 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -1,114 +1,114 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidencebase.h" | 27 | #include "incidencebase.h" |
28 | 28 | ||
29 | using namespace KCal; | 29 | using namespace KCal; |
30 | 30 | ||
31 | IncidenceBase::IncidenceBase() : | 31 | IncidenceBase::IncidenceBase() : |
32 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), | 32 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), |
33 | mPilotId(0), mSyncStatus(SYNCMOD) | 33 | mPilotId(0), mSyncStatus(SYNCMOD) |
34 | { | 34 | { |
35 | setUid(CalFormat::createUniqueId()); | 35 | setUid(CalFormat::createUniqueId()); |
36 | mOrganizer = ""; | 36 | mOrganizer = ""; |
37 | mFloats = false; | 37 | mFloats = false; |
38 | mDuration = 0; | 38 | mDuration = 0; |
39 | mHasDuration = false; | 39 | mHasDuration = false; |
40 | mPilotId = 0; | 40 | mPilotId = 0; |
41 | mZaurusId = -1; | 41 | mZaurusId = -1; |
42 | mZaurusUid = 0; | 42 | mZaurusUid = 0; |
43 | mZaurusStat = 0; | 43 | mTempSyncStat = 0; |
44 | mSyncStatus = 0; | 44 | mSyncStatus = 0; |
45 | mAttendees.setAutoDelete( true ); | 45 | mAttendees.setAutoDelete( true ); |
46 | } | 46 | } |
47 | 47 | ||
48 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 48 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
49 | CustomProperties( i ) | 49 | CustomProperties( i ) |
50 | { | 50 | { |
51 | mReadOnly = i.mReadOnly; | 51 | mReadOnly = i.mReadOnly; |
52 | mDtStart = i.mDtStart; | 52 | mDtStart = i.mDtStart; |
53 | mDuration = i.mDuration; | 53 | mDuration = i.mDuration; |
54 | mHasDuration = i.mHasDuration; | 54 | mHasDuration = i.mHasDuration; |
55 | mOrganizer = i.mOrganizer; | 55 | mOrganizer = i.mOrganizer; |
56 | mUid = i.mUid; | 56 | mUid = i.mUid; |
57 | QPtrList<Attendee> attendees = i.attendees(); | 57 | QPtrList<Attendee> attendees = i.attendees(); |
58 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 58 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
59 | mAttendees.append( new Attendee( *a ) ); | 59 | mAttendees.append( new Attendee( *a ) ); |
60 | } | 60 | } |
61 | mFloats = i.mFloats; | 61 | mFloats = i.mFloats; |
62 | mLastModified = i.mLastModified; | 62 | mLastModified = i.mLastModified; |
63 | mPilotId = i.mPilotId; | 63 | mPilotId = i.mPilotId; |
64 | mZaurusId = i.mZaurusId; | 64 | mZaurusId = i.mZaurusId; |
65 | mZaurusUid = i.mZaurusUid; | 65 | mZaurusUid = i.mZaurusUid; |
66 | mZaurusStat = i.mZaurusStat; | 66 | mTempSyncStat = i.mTempSyncStat; |
67 | mSyncStatus = i.mSyncStatus; | 67 | mSyncStatus = i.mSyncStatus; |
68 | 68 | ||
69 | // The copied object is a new one, so it isn't observed by the observer | 69 | // The copied object is a new one, so it isn't observed by the observer |
70 | // of the original object. | 70 | // of the original object. |
71 | mObservers.clear(); | 71 | mObservers.clear(); |
72 | 72 | ||
73 | mAttendees.setAutoDelete( true ); | 73 | mAttendees.setAutoDelete( true ); |
74 | } | 74 | } |
75 | 75 | ||
76 | IncidenceBase::~IncidenceBase() | 76 | IncidenceBase::~IncidenceBase() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 81 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
82 | { | 82 | { |
83 | 83 | ||
84 | if( i1.attendees().count() != i2.attendees().count() ) { | 84 | if( i1.attendees().count() != i2.attendees().count() ) { |
85 | return false; // no need to check further | 85 | return false; // no need to check further |
86 | } | 86 | } |
87 | if ( i1.attendees().count() > 0 ) { | 87 | if ( i1.attendees().count() > 0 ) { |
88 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 88 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
89 | while ( a1 ) { | 89 | while ( a1 ) { |
90 | if ( !( (*a1) == (*a2)) ) | 90 | if ( !( (*a1) == (*a2)) ) |
91 | { | 91 | { |
92 | //qDebug("Attendee not equal "); | 92 | //qDebug("Attendee not equal "); |
93 | return false; | 93 | return false; |
94 | } | 94 | } |
95 | a1 = i1.attendees().next(); | 95 | a1 = i1.attendees().next(); |
96 | a2 = i2.attendees().next(); | 96 | a2 = i2.attendees().next(); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | //if ( i1.dtStart() != i2.dtStart() ) | 99 | //if ( i1.dtStart() != i2.dtStart() ) |
100 | // return false; | 100 | // return false; |
101 | #if 0 | 101 | #if 0 |
102 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); | 102 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); |
103 | qDebug("1 %d ",i1.duration() == i2.duration() ); | 103 | qDebug("1 %d ",i1.duration() == i2.duration() ); |
104 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); | 104 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); |
105 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); | 105 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); |
106 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 106 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
107 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 107 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
108 | 108 | ||
109 | #endif | 109 | #endif |
110 | return ( i1.organizer() == i2.organizer() && | 110 | return ( i1.organizer() == i2.organizer() && |
111 | // i1.uid() == i2.uid() && | 111 | // i1.uid() == i2.uid() && |
112 | // Don't compare lastModified, otherwise the operator is not | 112 | // Don't compare lastModified, otherwise the operator is not |
113 | // of much use. We are not comparing for identity, after all. | 113 | // of much use. We are not comparing for identity, after all. |
114 | i1.doesFloat() == i2.doesFloat() && | 114 | i1.doesFloat() == i2.doesFloat() && |
@@ -317,77 +317,77 @@ void IncidenceBase::setHasDuration(bool b) | |||
317 | 317 | ||
318 | bool IncidenceBase::hasDuration() const | 318 | bool IncidenceBase::hasDuration() const |
319 | { | 319 | { |
320 | return mHasDuration; | 320 | return mHasDuration; |
321 | } | 321 | } |
322 | 322 | ||
323 | void IncidenceBase::setSyncStatus(int stat) | 323 | void IncidenceBase::setSyncStatus(int stat) |
324 | { | 324 | { |
325 | if (mReadOnly) return; | 325 | if (mReadOnly) return; |
326 | mSyncStatus = stat; | 326 | mSyncStatus = stat; |
327 | } | 327 | } |
328 | 328 | ||
329 | int IncidenceBase::syncStatus() const | 329 | int IncidenceBase::syncStatus() const |
330 | { | 330 | { |
331 | return mSyncStatus; | 331 | return mSyncStatus; |
332 | } | 332 | } |
333 | 333 | ||
334 | void IncidenceBase::setPilotId( int id ) | 334 | void IncidenceBase::setPilotId( int id ) |
335 | { | 335 | { |
336 | if (mReadOnly) return; | 336 | if (mReadOnly) return; |
337 | mPilotId = id; | 337 | mPilotId = id; |
338 | } | 338 | } |
339 | 339 | ||
340 | int IncidenceBase::pilotId() const | 340 | int IncidenceBase::pilotId() const |
341 | { | 341 | { |
342 | return mPilotId; | 342 | return mPilotId; |
343 | } | 343 | } |
344 | void IncidenceBase::setZaurusId( int id ) | 344 | void IncidenceBase::setZaurusId( int id ) |
345 | { | 345 | { |
346 | if (mReadOnly) return; | 346 | if (mReadOnly) return; |
347 | mZaurusId = id; | 347 | mZaurusId = id; |
348 | } | 348 | } |
349 | 349 | ||
350 | int IncidenceBase::zaurusId() const | 350 | int IncidenceBase::zaurusId() const |
351 | { | 351 | { |
352 | return mZaurusId; | 352 | return mZaurusId; |
353 | } | 353 | } |
354 | 354 | ||
355 | int IncidenceBase::zaurusUid() const | 355 | int IncidenceBase::zaurusUid() const |
356 | { | 356 | { |
357 | return mZaurusUid; | 357 | return mZaurusUid; |
358 | } | 358 | } |
359 | void IncidenceBase::setZaurusUid( int id ) | 359 | void IncidenceBase::setZaurusUid( int id ) |
360 | { | 360 | { |
361 | if (mReadOnly) return; | 361 | if (mReadOnly) return; |
362 | mZaurusUid = id; | 362 | mZaurusUid = id; |
363 | } | 363 | } |
364 | 364 | ||
365 | int IncidenceBase::zaurusStat() const | 365 | int IncidenceBase::tempSyncStat() const |
366 | { | 366 | { |
367 | return mZaurusStat; | 367 | return mTempSyncStat; |
368 | } | 368 | } |
369 | void IncidenceBase::setZaurusStat( int id ) | 369 | void IncidenceBase::setTempSyncStat( int id ) |
370 | { | 370 | { |
371 | if (mReadOnly) return; | 371 | if (mReadOnly) return; |
372 | mZaurusStat = id; | 372 | mTempSyncStat = id; |
373 | } | 373 | } |
374 | 374 | ||
375 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 375 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) |
376 | { | 376 | { |
377 | if( !mObservers.contains(observer) ) mObservers.append( observer ); | 377 | if( !mObservers.contains(observer) ) mObservers.append( observer ); |
378 | } | 378 | } |
379 | 379 | ||
380 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 380 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
381 | { | 381 | { |
382 | mObservers.remove( observer ); | 382 | mObservers.remove( observer ); |
383 | } | 383 | } |
384 | 384 | ||
385 | void IncidenceBase::updated() | 385 | void IncidenceBase::updated() |
386 | { | 386 | { |
387 | QPtrListIterator<Observer> it(mObservers); | 387 | QPtrListIterator<Observer> it(mObservers); |
388 | while( it.current() ) { | 388 | while( it.current() ) { |
389 | Observer *o = it.current(); | 389 | Observer *o = it.current(); |
390 | ++it; | 390 | ++it; |
391 | o->incidenceUpdated( this ); | 391 | o->incidenceUpdated( this ); |
392 | } | 392 | } |
393 | } | 393 | } |