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