summaryrefslogtreecommitdiffabout
path: root/libkcal/incidencebase.cpp
authorzautrix <zautrix>2004-08-01 12:02:39 (UTC)
committer zautrix <zautrix>2004-08-01 12:02:39 (UTC)
commitc31e99f265dbe8762efca20667f8ccd973840f8f (patch) (unidiff)
tree29e7fd6845d187f41f9d80e756611dc8bc182bdc /libkcal/incidencebase.cpp
parente954cc1e29b129982e4d07c4f490d7e881597374 (diff)
downloadkdepimpi-c31e99f265dbe8762efca20667f8ccd973840f8f.zip
kdepimpi-c31e99f265dbe8762efca20667f8ccd973840f8f.tar.gz
kdepimpi-c31e99f265dbe8762efca20667f8ccd973840f8f.tar.bz2
Changed zaurusstat to tempsyncstat
Diffstat (limited to 'libkcal/incidencebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidencebase.cpp12
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,393 +1,393 @@
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
29using namespace KCal; 29using namespace KCal;
30 30
31IncidenceBase::IncidenceBase() : 31IncidenceBase::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
48IncidenceBase::IncidenceBase(const IncidenceBase &i) : 48IncidenceBase::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
76IncidenceBase::~IncidenceBase() 76IncidenceBase::~IncidenceBase()
77{ 77{
78} 78}
79 79
80 80
81bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 81bool 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() &&
115 i1.duration() == i2.duration() && 115 i1.duration() == i2.duration() &&
116 i1.hasDuration() == i2.hasDuration() && 116 i1.hasDuration() == i2.hasDuration() &&
117 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 117 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
118 // no need to compare mObserver 118 // no need to compare mObserver
119} 119}
120 120
121 121
122QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 122QDateTime IncidenceBase::getEvenTime( QDateTime dt )
123{ 123{
124 QTime t = dt.time(); 124 QTime t = dt.time();
125 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 125 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
126 return dt; 126 return dt;
127} 127}
128 128
129 129
130void IncidenceBase::setUid(const QString &uid) 130void IncidenceBase::setUid(const QString &uid)
131{ 131{
132 mUid = uid; 132 mUid = uid;
133 updated(); 133 updated();
134} 134}
135 135
136QString IncidenceBase::uid() const 136QString IncidenceBase::uid() const
137{ 137{
138 return mUid; 138 return mUid;
139} 139}
140 140
141void IncidenceBase::setLastModified(const QDateTime &lm) 141void IncidenceBase::setLastModified(const QDateTime &lm)
142{ 142{
143 // DON'T! updated() because we call this from 143 // DON'T! updated() because we call this from
144 // Calendar::updateEvent(). 144 // Calendar::updateEvent().
145 mLastModified = getEvenTime(lm); 145 mLastModified = getEvenTime(lm);
146 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 146 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
147} 147}
148 148
149QDateTime IncidenceBase::lastModified() const 149QDateTime IncidenceBase::lastModified() const
150{ 150{
151 return mLastModified; 151 return mLastModified;
152} 152}
153 153
154void IncidenceBase::setOrganizer(const QString &o) 154void IncidenceBase::setOrganizer(const QString &o)
155{ 155{
156 // we don't check for readonly here, because it is 156 // we don't check for readonly here, because it is
157 // possible that by setting the organizer we are changing 157 // possible that by setting the organizer we are changing
158 // the event's readonly status... 158 // the event's readonly status...
159 mOrganizer = o; 159 mOrganizer = o;
160 if (mOrganizer.left(7).upper() == "MAILTO:") 160 if (mOrganizer.left(7).upper() == "MAILTO:")
161 mOrganizer = mOrganizer.remove(0,7); 161 mOrganizer = mOrganizer.remove(0,7);
162 162
163 updated(); 163 updated();
164} 164}
165 165
166QString IncidenceBase::organizer() const 166QString IncidenceBase::organizer() const
167{ 167{
168 return mOrganizer; 168 return mOrganizer;
169} 169}
170 170
171void IncidenceBase::setReadOnly( bool readOnly ) 171void IncidenceBase::setReadOnly( bool readOnly )
172{ 172{
173 mReadOnly = readOnly; 173 mReadOnly = readOnly;
174} 174}
175 175
176void IncidenceBase::setDtStart(const QDateTime &dtStart) 176void IncidenceBase::setDtStart(const QDateTime &dtStart)
177{ 177{
178// if (mReadOnly) return; 178// if (mReadOnly) return;
179 mDtStart = getEvenTime(dtStart); 179 mDtStart = getEvenTime(dtStart);
180 updated(); 180 updated();
181} 181}
182 182
183QDateTime IncidenceBase::dtStart() const 183QDateTime IncidenceBase::dtStart() const
184{ 184{
185 return mDtStart; 185 return mDtStart;
186} 186}
187 187
188QString IncidenceBase::dtStartTimeStr() const 188QString IncidenceBase::dtStartTimeStr() const
189{ 189{
190 return KGlobal::locale()->formatTime(dtStart().time()); 190 return KGlobal::locale()->formatTime(dtStart().time());
191} 191}
192 192
193QString IncidenceBase::dtStartDateStr(bool shortfmt) const 193QString IncidenceBase::dtStartDateStr(bool shortfmt) const
194{ 194{
195 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 195 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
196} 196}
197 197
198QString IncidenceBase::dtStartStr(bool shortfmt) const 198QString IncidenceBase::dtStartStr(bool shortfmt) const
199{ 199{
200 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); 200 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
201} 201}
202 202
203 203
204bool IncidenceBase::doesFloat() const 204bool IncidenceBase::doesFloat() const
205{ 205{
206 return mFloats; 206 return mFloats;
207} 207}
208 208
209void IncidenceBase::setFloats(bool f) 209void IncidenceBase::setFloats(bool f)
210{ 210{
211 if (mReadOnly) return; 211 if (mReadOnly) return;
212 mFloats = f; 212 mFloats = f;
213 updated(); 213 updated();
214} 214}
215 215
216 216
217void IncidenceBase::addAttendee(Attendee *a, bool doupdate) 217void IncidenceBase::addAttendee(Attendee *a, bool doupdate)
218{ 218{
219 if (mReadOnly) return; 219 if (mReadOnly) return;
220 if (a->name().left(7).upper() == "MAILTO:") 220 if (a->name().left(7).upper() == "MAILTO:")
221 a->setName(a->name().remove(0,7)); 221 a->setName(a->name().remove(0,7));
222 222
223 mAttendees.append(a); 223 mAttendees.append(a);
224 if (doupdate) updated(); 224 if (doupdate) updated();
225} 225}
226 226
227#if 0 227#if 0
228void IncidenceBase::removeAttendee(Attendee *a) 228void IncidenceBase::removeAttendee(Attendee *a)
229{ 229{
230 if (mReadOnly) return; 230 if (mReadOnly) return;
231 mAttendees.removeRef(a); 231 mAttendees.removeRef(a);
232 updated(); 232 updated();
233} 233}
234 234
235void IncidenceBase::removeAttendee(const char *n) 235void IncidenceBase::removeAttendee(const char *n)
236{ 236{
237 Attendee *a; 237 Attendee *a;
238 238
239 if (mReadOnly) return; 239 if (mReadOnly) return;
240 for (a = mAttendees.first(); a; a = mAttendees.next()) 240 for (a = mAttendees.first(); a; a = mAttendees.next())
241 if (a->getName() == n) { 241 if (a->getName() == n) {
242 mAttendees.remove(); 242 mAttendees.remove();
243 break; 243 break;
244 } 244 }
245} 245}
246#endif 246#endif
247 247
248void IncidenceBase::clearAttendees() 248void IncidenceBase::clearAttendees()
249{ 249{
250 if (mReadOnly) return; 250 if (mReadOnly) return;
251 mAttendees.clear(); 251 mAttendees.clear();
252} 252}
253 253
254#if 0 254#if 0
255Attendee *IncidenceBase::getAttendee(const char *n) const 255Attendee *IncidenceBase::getAttendee(const char *n) const
256{ 256{
257 QPtrListIterator<Attendee> qli(mAttendees); 257 QPtrListIterator<Attendee> qli(mAttendees);
258 258
259 qli.toFirst(); 259 qli.toFirst();
260 while (qli) { 260 while (qli) {
261 if (qli.current()->getName() == n) 261 if (qli.current()->getName() == n)
262 return qli.current(); 262 return qli.current();
263 ++qli; 263 ++qli;
264 } 264 }
265 return 0L; 265 return 0L;
266} 266}
267#endif 267#endif
268 268
269Attendee *IncidenceBase::attendeeByMail(const QString &email) 269Attendee *IncidenceBase::attendeeByMail(const QString &email)
270{ 270{
271 QPtrListIterator<Attendee> qli(mAttendees); 271 QPtrListIterator<Attendee> qli(mAttendees);
272 272
273 qli.toFirst(); 273 qli.toFirst();
274 while (qli) { 274 while (qli) {
275 if (qli.current()->email() == email) 275 if (qli.current()->email() == email)
276 return qli.current(); 276 return qli.current();
277 ++qli; 277 ++qli;
278 } 278 }
279 return 0L; 279 return 0L;
280} 280}
281 281
282Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) 282Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
283{ 283{
284 QPtrListIterator<Attendee> qli(mAttendees); 284 QPtrListIterator<Attendee> qli(mAttendees);
285 285
286 QStringList mails = emails; 286 QStringList mails = emails;
287 if (!email.isEmpty()) { 287 if (!email.isEmpty()) {
288 mails.append(email); 288 mails.append(email);
289 } 289 }
290 qli.toFirst(); 290 qli.toFirst();
291 while (qli) { 291 while (qli) {
292 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { 292 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
293 if (qli.current()->email() == *it) 293 if (qli.current()->email() == *it)
294 return qli.current(); 294 return qli.current();
295 } 295 }
296 296
297 ++qli; 297 ++qli;
298 } 298 }
299 return 0L; 299 return 0L;
300} 300}
301 301
302void IncidenceBase::setDuration(int seconds) 302void IncidenceBase::setDuration(int seconds)
303{ 303{
304 mDuration = seconds; 304 mDuration = seconds;
305 setHasDuration(true); 305 setHasDuration(true);
306} 306}
307 307
308int IncidenceBase::duration() const 308int IncidenceBase::duration() const
309{ 309{
310 return mDuration; 310 return mDuration;
311} 311}
312 312
313void IncidenceBase::setHasDuration(bool b) 313void IncidenceBase::setHasDuration(bool b)
314{ 314{
315 mHasDuration = b; 315 mHasDuration = b;
316} 316}
317 317
318bool IncidenceBase::hasDuration() const 318bool IncidenceBase::hasDuration() const
319{ 319{
320 return mHasDuration; 320 return mHasDuration;
321} 321}
322 322
323void IncidenceBase::setSyncStatus(int stat) 323void IncidenceBase::setSyncStatus(int stat)
324{ 324{
325 if (mReadOnly) return; 325 if (mReadOnly) return;
326 mSyncStatus = stat; 326 mSyncStatus = stat;
327} 327}
328 328
329int IncidenceBase::syncStatus() const 329int IncidenceBase::syncStatus() const
330{ 330{
331 return mSyncStatus; 331 return mSyncStatus;
332} 332}
333 333
334void IncidenceBase::setPilotId( int id ) 334void IncidenceBase::setPilotId( int id )
335{ 335{
336 if (mReadOnly) return; 336 if (mReadOnly) return;
337 mPilotId = id; 337 mPilotId = id;
338} 338}
339 339
340int IncidenceBase::pilotId() const 340int IncidenceBase::pilotId() const
341{ 341{
342 return mPilotId; 342 return mPilotId;
343} 343}
344void IncidenceBase::setZaurusId( int id ) 344void IncidenceBase::setZaurusId( int id )
345{ 345{
346 if (mReadOnly) return; 346 if (mReadOnly) return;
347 mZaurusId = id; 347 mZaurusId = id;
348} 348}
349 349
350int IncidenceBase::zaurusId() const 350int IncidenceBase::zaurusId() const
351{ 351{
352 return mZaurusId; 352 return mZaurusId;
353} 353}
354 354
355int IncidenceBase::zaurusUid() const 355int IncidenceBase::zaurusUid() const
356{ 356{
357 return mZaurusUid; 357 return mZaurusUid;
358} 358}
359void IncidenceBase::setZaurusUid( int id ) 359void IncidenceBase::setZaurusUid( int id )
360{ 360{
361 if (mReadOnly) return; 361 if (mReadOnly) return;
362 mZaurusUid = id; 362 mZaurusUid = id;
363} 363}
364 364
365int IncidenceBase::zaurusStat() const 365int IncidenceBase::tempSyncStat() const
366{ 366{
367 return mZaurusStat; 367 return mTempSyncStat;
368} 368}
369void IncidenceBase::setZaurusStat( int id ) 369void IncidenceBase::setTempSyncStat( int id )
370{ 370{
371 if (mReadOnly) return; 371 if (mReadOnly) return;
372 mZaurusStat = id; 372 mTempSyncStat = id;
373} 373}
374 374
375void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 375void 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
380void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) 380void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
381{ 381{
382 mObservers.remove( observer ); 382 mObservers.remove( observer );
383} 383}
384 384
385void IncidenceBase::updated() 385void 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}