summaryrefslogtreecommitdiffabout
path: root/libkcal/incidencebase.cpp
Unidiff
Diffstat (limited to 'libkcal/incidencebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidencebase.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index b5fe2e6..2ddbb01 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -1,182 +1,215 @@
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#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 30
31using namespace KCal; 31using namespace KCal;
32 32
33IncidenceBase::IncidenceBase() : 33IncidenceBase::IncidenceBase() :
34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
35 mPilotId(0), mSyncStatus(SYNCMOD) 35 mPilotId(0), mSyncStatus(SYNCMOD)
36{ 36{
37 setUid(CalFormat::createUniqueId()); 37 setUid(CalFormat::createUniqueId());
38 mOrganizer = ""; 38 mOrganizer = "";
39 mFloats = false; 39 mFloats = false;
40 mDuration = 0; 40 mDuration = 0;
41 mHasDuration = false; 41 mHasDuration = false;
42 mPilotId = 0; 42 mPilotId = 0;
43 mExternalId = ":"; 43 mExternalId = ":";
44 mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 44 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
45 mSyncStatus = 0; 45 mSyncStatus = 0;
46 mAttendees.setAutoDelete( true ); 46 mAttendees.setAutoDelete( true );
47 mCalEnabled = true;
48 mAlarmEnabled = true;
49 mCalID = 0;
47} 50}
48 51
49IncidenceBase::IncidenceBase(const IncidenceBase &i) : 52IncidenceBase::IncidenceBase(const IncidenceBase &i) :
50 CustomProperties( i ) 53 CustomProperties( i )
51{ 54{
55
52 mReadOnly = i.mReadOnly; 56 mReadOnly = i.mReadOnly;
53 mDtStart = i.mDtStart; 57 mDtStart = i.mDtStart;
54 mDuration = i.mDuration; 58 mDuration = i.mDuration;
55 mHasDuration = i.mHasDuration; 59 mHasDuration = i.mHasDuration;
56 mOrganizer = i.mOrganizer; 60 mOrganizer = i.mOrganizer;
57 mUid = i.mUid; 61 mUid = i.mUid;
62 mCalEnabled = i.mCalEnabled;
63 mAlarmEnabled = i.mAlarmEnabled;
64 mCalID = i.mCalID;
58 QPtrList<Attendee> attendees = i.attendees(); 65 QPtrList<Attendee> attendees = i.attendees();
59 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 66 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
60 mAttendees.append( new Attendee( *a ) ); 67 mAttendees.append( new Attendee( *a ) );
61 } 68 }
62 mFloats = i.mFloats; 69 mFloats = i.mFloats;
63 mLastModified = i.mLastModified; 70 mLastModified = i.mLastModified;
64 mPilotId = i.mPilotId; 71 mPilotId = i.mPilotId;
65 mTempSyncStat = i.mTempSyncStat; 72 mTempSyncStat = i.mTempSyncStat;
66 mSyncStatus = i.mSyncStatus; 73 mSyncStatus = i.mSyncStatus;
67 mExternalId = i.mExternalId; 74 mExternalId = i.mExternalId;
68 // The copied object is a new one, so it isn't observed by the observer 75 // The copied object is a new one, so it isn't observed by the observer
69 // of the original object. 76 // of the original object.
70 mObservers.clear(); 77 mObservers.clear();
71 78
72 mAttendees.setAutoDelete( true ); 79 mAttendees.setAutoDelete( true );
73} 80}
74 81
75IncidenceBase::~IncidenceBase() 82IncidenceBase::~IncidenceBase()
76{ 83{
77} 84}
78 85
79 86
80bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 87bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
81{ 88{
82 // do not compare mSyncStatus and mExternalId 89 // do not compare mSyncStatus and mExternalId
83 if( i1.attendees().count() != i2.attendees().count() ) { 90 if( i1.attendees().count() != i2.attendees().count() ) {
84 return false; // no need to check further 91 return false; // no need to check further
85 } 92 }
86 if ( i1.attendees().count() > 0 ) { 93 if ( i1.attendees().count() > 0 ) {
87 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 94 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
88 while ( a1 ) { 95 while ( a1 ) {
89 if ( !( (*a1) == (*a2)) ) 96 if ( !( (*a1) == (*a2)) )
90 { 97 {
91 //qDebug("Attendee not equal "); 98 //qDebug("Attendee not equal ");
92 return false; 99 return false;
93 } 100 }
94 a1 = i1.attendees().next(); 101 a1 = i1.attendees().next();
95 a2 = i2.attendees().next(); 102 a2 = i2.attendees().next();
96 } 103 }
97 } 104 }
98 //if ( i1.dtStart() != i2.dtStart() ) 105 //if ( i1.dtStart() != i2.dtStart() )
99 // return false; 106 // return false;
100#if 0 107#if 0
101 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); 108 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
102 qDebug("1 %d ",i1.duration() == i2.duration() ); 109 qDebug("1 %d ",i1.duration() == i2.duration() );
103 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); 110 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
104 qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); 111 qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
105 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); 112 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
106 qDebug("6 %d ",i1.organizer() == i2.organizer() ); 113 qDebug("6 %d ",i1.organizer() == i2.organizer() );
107 114
108#endif 115#endif
109 if ( i1.hasDuration() == i2.hasDuration() ) { 116 if ( i1.hasDuration() == i2.hasDuration() ) {
110 if ( i1.hasDuration() ) { 117 if ( i1.hasDuration() ) {
111 if ( i1.duration() != i2.duration() ) 118 if ( i1.duration() != i2.duration() )
112 return false; 119 return false;
113 } 120 }
114 } else { 121 } else {
115 return false; 122 return false;
116 } 123 }
117 124
118 return ( i1.organizer() == i2.organizer() && 125 return ( i1.organizer() == i2.organizer() &&
119 // i1.uid() == i2.uid() && 126 // i1.uid() == i2.uid() &&
120 // Don't compare lastModified, otherwise the operator is not 127 // Don't compare lastModified, otherwise the operator is not
121 // of much use. We are not comparing for identity, after all. 128 // of much use. We are not comparing for identity, after all.
122 i1.doesFloat() == i2.doesFloat() && 129 i1.doesFloat() == i2.doesFloat() &&
123 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 130 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
124 // no need to compare mObserver 131 // no need to compare mObserver
125} 132}
126 133
127 134
128QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 135QDateTime IncidenceBase::getEvenTime( QDateTime dt )
129{ 136{
130 QTime t = dt.time(); 137 QTime t = dt.time();
131 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 138 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
132 return dt; 139 return dt;
133} 140}
134 141
142void IncidenceBase::setCalID( int id )
143{
144 mCalID = id;
145}
146int IncidenceBase::calID() const
147{
148 return mCalID;
149}
150void IncidenceBase::setCalEnabled( bool b )
151{
152 mCalEnabled = b;
153}
154bool IncidenceBase::calEnabled() const
155{
156 return mCalEnabled;
157}
158
159void IncidenceBase::setAlarmEnabled( bool b )
160{
161 mAlarmEnabled = b;
162}
163bool IncidenceBase::alarmEnabled() const
164{
165 return mAlarmEnabled;
166}
167
135 168
136void IncidenceBase::setUid(const QString &uid) 169void IncidenceBase::setUid(const QString &uid)
137{ 170{
138 mUid = uid; 171 mUid = uid;
139 updated(); 172 updated();
140} 173}
141 174
142QString IncidenceBase::uid() const 175QString IncidenceBase::uid() const
143{ 176{
144 return mUid; 177 return mUid;
145} 178}
146 179
147void IncidenceBase::setLastModified(const QDateTime &lm) 180void IncidenceBase::setLastModified(const QDateTime &lm)
148{ 181{
149 // DON'T! updated() because we call this from 182 // DON'T! updated() because we call this from
150 // Calendar::updateEvent(). 183 // Calendar::updateEvent().
151 mLastModified = getEvenTime(lm); 184 mLastModified = getEvenTime(lm);
152 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 185 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
153} 186}
154 187
155QDateTime IncidenceBase::lastModified() const 188QDateTime IncidenceBase::lastModified() const
156{ 189{
157 return mLastModified; 190 return mLastModified;
158} 191}
159 192
160void IncidenceBase::setOrganizer(const QString &o) 193void IncidenceBase::setOrganizer(const QString &o)
161{ 194{
162 // we don't check for readonly here, because it is 195 // we don't check for readonly here, because it is
163 // possible that by setting the organizer we are changing 196 // possible that by setting the organizer we are changing
164 // the event's readonly status... 197 // the event's readonly status...
165 mOrganizer = o; 198 mOrganizer = o;
166 if (mOrganizer.left(7).upper() == "MAILTO:") 199 if (mOrganizer.left(7).upper() == "MAILTO:")
167 mOrganizer = mOrganizer.remove(0,7); 200 mOrganizer = mOrganizer.remove(0,7);
168 201
169 updated(); 202 updated();
170} 203}
171 204
172QString IncidenceBase::organizer() const 205QString IncidenceBase::organizer() const
173{ 206{
174 return mOrganizer; 207 return mOrganizer;
175} 208}
176 209
177void IncidenceBase::setReadOnly( bool readOnly ) 210void IncidenceBase::setReadOnly( bool readOnly )
178{ 211{
179 mReadOnly = readOnly; 212 mReadOnly = readOnly;
180} 213}
181 214
182void IncidenceBase::setDtStart(const QDateTime &dtStart) 215void IncidenceBase::setDtStart(const QDateTime &dtStart)