summaryrefslogtreecommitdiffabout
path: root/libkcal/incidencebase.cpp
Unidiff
Diffstat (limited to 'libkcal/incidencebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidencebase.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 56c0560..f11ec54 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -6,86 +6,88 @@
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#include <kidmanager.h> 24#include <kidmanager.h>
25 25
26#include "calformat.h" 26#include "calformat.h"
27#include "syncdefines.h" 27#include "syncdefines.h"
28 28
29#include "incidencebase.h" 29#include "incidencebase.h"
30//Added by qt3to4:
31#include <Q3PtrList>
30 32
31using namespace KCal; 33using namespace KCal;
32 34
33IncidenceBase::IncidenceBase() : 35IncidenceBase::IncidenceBase() :
34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 36 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
35 mPilotId(0), mSyncStatus(SYNCMOD) 37 mPilotId(0), mSyncStatus(SYNCMOD)
36{ 38{
37 blockLastModified = false; 39 blockLastModified = false;
38 setUid(CalFormat::createUniqueId()); 40 setUid(CalFormat::createUniqueId());
39 mOrganizer = ""; 41 mOrganizer = "";
40 mFloats = false; 42 mFloats = false;
41 mDuration = 0; 43 mDuration = 0;
42 mHasDuration = false; 44 mHasDuration = false;
43 mPilotId = 0; 45 mPilotId = 0;
44 mExternalId = ":"; 46 mExternalId = ":";
45 mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 47 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
46 mSyncStatus = 0; 48 mSyncStatus = 0;
47 mAttendees.setAutoDelete( true ); 49 mAttendees.setAutoDelete( true );
48 mCalEnabled = true; 50 mCalEnabled = true;
49 mAlarmEnabled = true; 51 mAlarmEnabled = true;
50 mCalID = 0; 52 mCalID = 0;
51} 53}
52 54
53IncidenceBase::IncidenceBase(const IncidenceBase &i) : 55IncidenceBase::IncidenceBase(const IncidenceBase &i) :
54 CustomProperties( i ) 56 CustomProperties( i )
55{ 57{
56 58
57 blockLastModified = false; 59 blockLastModified = false;
58 mReadOnly = i.mReadOnly; 60 mReadOnly = i.mReadOnly;
59 mDtStart = i.mDtStart; 61 mDtStart = i.mDtStart;
60 mDuration = i.mDuration; 62 mDuration = i.mDuration;
61 mHasDuration = i.mHasDuration; 63 mHasDuration = i.mHasDuration;
62 mOrganizer = i.mOrganizer; 64 mOrganizer = i.mOrganizer;
63 mUid = i.mUid; 65 mUid = i.mUid;
64 mCalEnabled = i.mCalEnabled; 66 mCalEnabled = i.mCalEnabled;
65 mAlarmEnabled = i.mAlarmEnabled; 67 mAlarmEnabled = i.mAlarmEnabled;
66 mCalID = i.mCalID; 68 mCalID = i.mCalID;
67 QPtrList<Attendee> attendees = i.attendees(); 69 Q3PtrList<Attendee> attendees = i.attendees();
68 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 70 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
69 mAttendees.append( new Attendee( *a ) ); 71 mAttendees.append( new Attendee( *a ) );
70 } 72 }
71 mFloats = i.mFloats; 73 mFloats = i.mFloats;
72 mLastModified = i.mLastModified; 74 mLastModified = i.mLastModified;
73 mPilotId = i.mPilotId; 75 mPilotId = i.mPilotId;
74 mTempSyncStat = i.mTempSyncStat; 76 mTempSyncStat = i.mTempSyncStat;
75 mSyncStatus = i.mSyncStatus; 77 mSyncStatus = i.mSyncStatus;
76 mExternalId = i.mExternalId; 78 mExternalId = i.mExternalId;
77 // The copied object is a new one, so it isn't observed by the observer 79 // The copied object is a new one, so it isn't observed by the observer
78 // of the original object. 80 // of the original object.
79 mObservers.clear(); 81 mObservers.clear();
80 82
81 mAttendees.setAutoDelete( true ); 83 mAttendees.setAutoDelete( true );
82} 84}
83 85
84IncidenceBase::~IncidenceBase() 86IncidenceBase::~IncidenceBase()
85{ 87{
86} 88}
87 89
88 90
89bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 91bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
90{ 92{
91 // do not compare mSyncStatus and mExternalId 93 // do not compare mSyncStatus and mExternalId
@@ -279,119 +281,119 @@ QString IncidenceBase::dtStartStr(bool shortfmt) const
279 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 281 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
280 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); 282 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
281} 283}
282 284
283 285
284bool IncidenceBase::doesFloat() const 286bool IncidenceBase::doesFloat() const
285{ 287{
286 return mFloats; 288 return mFloats;
287} 289}
288 290
289void IncidenceBase::setFloats(bool f) 291void IncidenceBase::setFloats(bool f)
290{ 292{
291 if (mReadOnly) return; 293 if (mReadOnly) return;
292 mFloats = f; 294 mFloats = f;
293 updated(); 295 updated();
294} 296}
295 297
296 298
297bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) 299bool IncidenceBase::addAttendee(Attendee *a, bool doupdate)
298{ 300{
299 if (mReadOnly) return false; 301 if (mReadOnly) return false;
300 if (a->name().left(7).upper() == "MAILTO:") 302 if (a->name().left(7).upper() == "MAILTO:")
301 a->setName(a->name().remove(0,7)); 303 a->setName(a->name().remove(0,7));
302 304
303 QPtrListIterator<Attendee> qli(mAttendees); 305 Q3PtrListIterator<Attendee> qli(mAttendees);
304 306
305 qli.toFirst(); 307 qli.toFirst();
306 while (qli) { 308 while (qli) {
307 if (*qli.current() == *a) 309 if (*qli.current() == *a)
308 return false; 310 return false;
309 ++qli; 311 ++qli;
310 } 312 }
311 mAttendees.append(a); 313 mAttendees.append(a);
312 if (doupdate) updated(); 314 if (doupdate) updated();
313 return true; 315 return true;
314} 316}
315 317
316#if 0 318#if 0
317void IncidenceBase::removeAttendee(Attendee *a) 319void IncidenceBase::removeAttendee(Attendee *a)
318{ 320{
319 if (mReadOnly) return; 321 if (mReadOnly) return;
320 mAttendees.removeRef(a); 322 mAttendees.removeRef(a);
321 updated(); 323 updated();
322} 324}
323 325
324void IncidenceBase::removeAttendee(const char *n) 326void IncidenceBase::removeAttendee(const char *n)
325{ 327{
326 Attendee *a; 328 Attendee *a;
327 329
328 if (mReadOnly) return; 330 if (mReadOnly) return;
329 for (a = mAttendees.first(); a; a = mAttendees.next()) 331 for (a = mAttendees.first(); a; a = mAttendees.next())
330 if (a->getName() == n) { 332 if (a->getName() == n) {
331 mAttendees.remove(); 333 mAttendees.remove();
332 break; 334 break;
333 } 335 }
334} 336}
335#endif 337#endif
336 338
337void IncidenceBase::clearAttendees() 339void IncidenceBase::clearAttendees()
338{ 340{
339 if (mReadOnly) return; 341 if (mReadOnly) return;
340 mAttendees.clear(); 342 mAttendees.clear();
341} 343}
342 344
343#if 0 345#if 0
344Attendee *IncidenceBase::getAttendee(const char *n) const 346Attendee *IncidenceBase::getAttendee(const char *n) const
345{ 347{
346 QPtrListIterator<Attendee> qli(mAttendees); 348 Q3PtrListIterator<Attendee> qli(mAttendees);
347 349
348 qli.toFirst(); 350 qli.toFirst();
349 while (qli) { 351 while (qli) {
350 if (qli.current()->getName() == n) 352 if (qli.current()->getName() == n)
351 return qli.current(); 353 return qli.current();
352 ++qli; 354 ++qli;
353 } 355 }
354 return 0L; 356 return 0L;
355} 357}
356#endif 358#endif
357 359
358Attendee *IncidenceBase::attendeeByMail(const QString &email) 360Attendee *IncidenceBase::attendeeByMail(const QString &email)
359{ 361{
360 QPtrListIterator<Attendee> qli(mAttendees); 362 Q3PtrListIterator<Attendee> qli(mAttendees);
361 363
362 qli.toFirst(); 364 qli.toFirst();
363 while (qli) { 365 while (qli) {
364 if (qli.current()->email().lower() == email.lower()) 366 if (qli.current()->email().lower() == email.lower())
365 return qli.current(); 367 return qli.current();
366 ++qli; 368 ++qli;
367 } 369 }
368 return 0L; 370 return 0L;
369} 371}
370 372
371Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) 373Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
372{ 374{
373 QPtrListIterator<Attendee> qli(mAttendees); 375 Q3PtrListIterator<Attendee> qli(mAttendees);
374 376
375 QStringList mails = emails; 377 QStringList mails = emails;
376 if (!email.isEmpty()) { 378 if (!email.isEmpty()) {
377 mails.append(email); 379 mails.append(email);
378 } 380 }
379 qli.toFirst(); 381 qli.toFirst();
380 while (qli) { 382 while (qli) {
381 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { 383 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
382 if (qli.current()->email().lower() == (*it).lower()) 384 if (qli.current()->email().lower() == (*it).lower())
383 return qli.current(); 385 return qli.current();
384 } 386 }
385 387
386 ++qli; 388 ++qli;
387 } 389 }
388 return 0L; 390 return 0L;
389} 391}
390 392
391void IncidenceBase::setDuration(int seconds) 393void IncidenceBase::setDuration(int seconds)
392{ 394{
393 mDuration = seconds; 395 mDuration = seconds;
394 setHasDuration(true); 396 setHasDuration(true);
395} 397}
396 398
397int IncidenceBase::duration() const 399int IncidenceBase::duration() const
@@ -470,31 +472,31 @@ QString IncidenceBase::getCsum( const QString & prof)
470} 472}
471 473
472void IncidenceBase::setIDStr( const QString & s ) 474void IncidenceBase::setIDStr( const QString & s )
473{ 475{
474 if (mReadOnly) return; 476 if (mReadOnly) return;
475 mExternalId = s; 477 mExternalId = s;
476} 478}
477 479
478QString IncidenceBase::IDStr() const 480QString IncidenceBase::IDStr() const
479{ 481{
480 return mExternalId ; 482 return mExternalId ;
481} 483}
482void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 484void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
483{ 485{
484 if( !mObservers.contains(observer) ) mObservers.append( observer ); 486 if( !mObservers.contains(observer) ) mObservers.append( observer );
485} 487}
486 488
487void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) 489void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
488{ 490{
489 mObservers.remove( observer ); 491 mObservers.remove( observer );
490} 492}
491 493
492void IncidenceBase::updated() 494void IncidenceBase::updated()
493{ 495{
494 QPtrListIterator<Observer> it(mObservers); 496 Q3PtrListIterator<Observer> it(mObservers);
495 while( it.current() ) { 497 while( it.current() ) {
496 Observer *o = it.current(); 498 Observer *o = it.current();
497 ++it; 499 ++it;
498 o->incidenceUpdated( this ); 500 o->incidenceUpdated( this );
499 } 501 }
500} 502}