-rw-r--r-- | libkcal/incidencebase.cpp | 13 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 9aa517c..7525a4a 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -152,136 +152,145 @@ QDateTime IncidenceBase::lastModified() const | |||
152 | 152 | ||
153 | void IncidenceBase::setOrganizer(const QString &o) | 153 | void IncidenceBase::setOrganizer(const QString &o) |
154 | { | 154 | { |
155 | // we don't check for readonly here, because it is | 155 | // we don't check for readonly here, because it is |
156 | // possible that by setting the organizer we are changing | 156 | // possible that by setting the organizer we are changing |
157 | // the event's readonly status... | 157 | // the event's readonly status... |
158 | mOrganizer = o; | 158 | mOrganizer = o; |
159 | if (mOrganizer.left(7).upper() == "MAILTO:") | 159 | if (mOrganizer.left(7).upper() == "MAILTO:") |
160 | mOrganizer = mOrganizer.remove(0,7); | 160 | mOrganizer = mOrganizer.remove(0,7); |
161 | 161 | ||
162 | updated(); | 162 | updated(); |
163 | } | 163 | } |
164 | 164 | ||
165 | QString IncidenceBase::organizer() const | 165 | QString IncidenceBase::organizer() const |
166 | { | 166 | { |
167 | return mOrganizer; | 167 | return mOrganizer; |
168 | } | 168 | } |
169 | 169 | ||
170 | void IncidenceBase::setReadOnly( bool readOnly ) | 170 | void IncidenceBase::setReadOnly( bool readOnly ) |
171 | { | 171 | { |
172 | mReadOnly = readOnly; | 172 | mReadOnly = readOnly; |
173 | } | 173 | } |
174 | 174 | ||
175 | void IncidenceBase::setDtStart(const QDateTime &dtStart) | 175 | void IncidenceBase::setDtStart(const QDateTime &dtStart) |
176 | { | 176 | { |
177 | // if (mReadOnly) return; | 177 | // if (mReadOnly) return; |
178 | mDtStart = getEvenTime(dtStart); | 178 | mDtStart = getEvenTime(dtStart); |
179 | updated(); | 179 | updated(); |
180 | } | 180 | } |
181 | 181 | ||
182 | QDateTime IncidenceBase::dtStart() const | 182 | QDateTime IncidenceBase::dtStart() const |
183 | { | 183 | { |
184 | return mDtStart; | 184 | return mDtStart; |
185 | } | 185 | } |
186 | 186 | ||
187 | QString IncidenceBase::dtStartTimeStr() const | 187 | QString IncidenceBase::dtStartTimeStr() const |
188 | { | 188 | { |
189 | return KGlobal::locale()->formatTime(dtStart().time()); | 189 | return KGlobal::locale()->formatTime(dtStart().time()); |
190 | } | 190 | } |
191 | 191 | ||
192 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const | 192 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const |
193 | { | 193 | { |
194 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 194 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
195 | } | 195 | } |
196 | 196 | ||
197 | QString IncidenceBase::dtStartStr(bool shortfmt) const | 197 | QString IncidenceBase::dtStartStr(bool shortfmt) const |
198 | { | 198 | { |
199 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); | 199 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); |
200 | } | 200 | } |
201 | 201 | ||
202 | 202 | ||
203 | bool IncidenceBase::doesFloat() const | 203 | bool IncidenceBase::doesFloat() const |
204 | { | 204 | { |
205 | return mFloats; | 205 | return mFloats; |
206 | } | 206 | } |
207 | 207 | ||
208 | void IncidenceBase::setFloats(bool f) | 208 | void IncidenceBase::setFloats(bool f) |
209 | { | 209 | { |
210 | if (mReadOnly) return; | 210 | if (mReadOnly) return; |
211 | mFloats = f; | 211 | mFloats = f; |
212 | updated(); | 212 | updated(); |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | void IncidenceBase::addAttendee(Attendee *a, bool doupdate) | 216 | bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) |
217 | { | 217 | { |
218 | if (mReadOnly) return; | 218 | if (mReadOnly) return false; |
219 | if (a->name().left(7).upper() == "MAILTO:") | 219 | if (a->name().left(7).upper() == "MAILTO:") |
220 | a->setName(a->name().remove(0,7)); | 220 | a->setName(a->name().remove(0,7)); |
221 | 221 | ||
222 | QPtrListIterator<Attendee> qli(mAttendees); | ||
223 | |||
224 | qli.toFirst(); | ||
225 | while (qli) { | ||
226 | if (*qli.current() == *a) | ||
227 | return false; | ||
228 | ++qli; | ||
229 | } | ||
222 | mAttendees.append(a); | 230 | mAttendees.append(a); |
223 | if (doupdate) updated(); | 231 | if (doupdate) updated(); |
232 | return true; | ||
224 | } | 233 | } |
225 | 234 | ||
226 | #if 0 | 235 | #if 0 |
227 | void IncidenceBase::removeAttendee(Attendee *a) | 236 | void IncidenceBase::removeAttendee(Attendee *a) |
228 | { | 237 | { |
229 | if (mReadOnly) return; | 238 | if (mReadOnly) return; |
230 | mAttendees.removeRef(a); | 239 | mAttendees.removeRef(a); |
231 | updated(); | 240 | updated(); |
232 | } | 241 | } |
233 | 242 | ||
234 | void IncidenceBase::removeAttendee(const char *n) | 243 | void IncidenceBase::removeAttendee(const char *n) |
235 | { | 244 | { |
236 | Attendee *a; | 245 | Attendee *a; |
237 | 246 | ||
238 | if (mReadOnly) return; | 247 | if (mReadOnly) return; |
239 | for (a = mAttendees.first(); a; a = mAttendees.next()) | 248 | for (a = mAttendees.first(); a; a = mAttendees.next()) |
240 | if (a->getName() == n) { | 249 | if (a->getName() == n) { |
241 | mAttendees.remove(); | 250 | mAttendees.remove(); |
242 | break; | 251 | break; |
243 | } | 252 | } |
244 | } | 253 | } |
245 | #endif | 254 | #endif |
246 | 255 | ||
247 | void IncidenceBase::clearAttendees() | 256 | void IncidenceBase::clearAttendees() |
248 | { | 257 | { |
249 | if (mReadOnly) return; | 258 | if (mReadOnly) return; |
250 | mAttendees.clear(); | 259 | mAttendees.clear(); |
251 | } | 260 | } |
252 | 261 | ||
253 | #if 0 | 262 | #if 0 |
254 | Attendee *IncidenceBase::getAttendee(const char *n) const | 263 | Attendee *IncidenceBase::getAttendee(const char *n) const |
255 | { | 264 | { |
256 | QPtrListIterator<Attendee> qli(mAttendees); | 265 | QPtrListIterator<Attendee> qli(mAttendees); |
257 | 266 | ||
258 | qli.toFirst(); | 267 | qli.toFirst(); |
259 | while (qli) { | 268 | while (qli) { |
260 | if (qli.current()->getName() == n) | 269 | if (qli.current()->getName() == n) |
261 | return qli.current(); | 270 | return qli.current(); |
262 | ++qli; | 271 | ++qli; |
263 | } | 272 | } |
264 | return 0L; | 273 | return 0L; |
265 | } | 274 | } |
266 | #endif | 275 | #endif |
267 | 276 | ||
268 | Attendee *IncidenceBase::attendeeByMail(const QString &email) | 277 | Attendee *IncidenceBase::attendeeByMail(const QString &email) |
269 | { | 278 | { |
270 | QPtrListIterator<Attendee> qli(mAttendees); | 279 | QPtrListIterator<Attendee> qli(mAttendees); |
271 | 280 | ||
272 | qli.toFirst(); | 281 | qli.toFirst(); |
273 | while (qli) { | 282 | while (qli) { |
274 | if (qli.current()->email().lower() == email.lower()) | 283 | if (qli.current()->email().lower() == email.lower()) |
275 | return qli.current(); | 284 | return qli.current(); |
276 | ++qli; | 285 | ++qli; |
277 | } | 286 | } |
278 | return 0L; | 287 | return 0L; |
279 | } | 288 | } |
280 | 289 | ||
281 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) | 290 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) |
282 | { | 291 | { |
283 | QPtrListIterator<Attendee> qli(mAttendees); | 292 | QPtrListIterator<Attendee> qli(mAttendees); |
284 | 293 | ||
285 | QStringList mails = emails; | 294 | QStringList mails = emails; |
286 | if (!email.isEmpty()) { | 295 | if (!email.isEmpty()) { |
287 | mails.append(email); | 296 | mails.append(email); |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index e02d03a..f9a6558 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -39,129 +39,129 @@ typedef QValueList<QDate> DateList; | |||
39 | This class provides the base class common to all calendar components. | 39 | This class provides the base class common to all calendar components. |
40 | */ | 40 | */ |
41 | class IncidenceBase : public CustomProperties | 41 | class IncidenceBase : public CustomProperties |
42 | { | 42 | { |
43 | public: | 43 | public: |
44 | class Observer { | 44 | class Observer { |
45 | public: | 45 | public: |
46 | virtual void incidenceUpdated( IncidenceBase * ) = 0; | 46 | virtual void incidenceUpdated( IncidenceBase * ) = 0; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | IncidenceBase(); | 49 | IncidenceBase(); |
50 | IncidenceBase(const IncidenceBase &); | 50 | IncidenceBase(const IncidenceBase &); |
51 | virtual ~IncidenceBase(); | 51 | virtual ~IncidenceBase(); |
52 | 52 | ||
53 | virtual QCString type() const = 0; | 53 | virtual QCString type() const = 0; |
54 | 54 | ||
55 | /** Set the unique id for the event */ | 55 | /** Set the unique id for the event */ |
56 | void setUid(const QString &); | 56 | void setUid(const QString &); |
57 | /** Return the unique id for the event */ | 57 | /** Return the unique id for the event */ |
58 | QString uid() const; | 58 | QString uid() const; |
59 | 59 | ||
60 | /** Sets the time the incidence was last modified. */ | 60 | /** Sets the time the incidence was last modified. */ |
61 | void setLastModified(const QDateTime &lm); | 61 | void setLastModified(const QDateTime &lm); |
62 | /** Return the time the incidence was last modified. */ | 62 | /** Return the time the incidence was last modified. */ |
63 | QDateTime lastModified() const; | 63 | QDateTime lastModified() const; |
64 | 64 | ||
65 | /** sets the organizer for the event */ | 65 | /** sets the organizer for the event */ |
66 | void setOrganizer(const QString &o); | 66 | void setOrganizer(const QString &o); |
67 | QString organizer() const; | 67 | QString organizer() const; |
68 | 68 | ||
69 | /** Set readonly status. */ | 69 | /** Set readonly status. */ |
70 | virtual void setReadOnly( bool ); | 70 | virtual void setReadOnly( bool ); |
71 | /** Return if the object is read-only. */ | 71 | /** Return if the object is read-only. */ |
72 | bool isReadOnly() const { return mReadOnly; } | 72 | bool isReadOnly() const { return mReadOnly; } |
73 | 73 | ||
74 | /** for setting the event's starting date/time with a QDateTime. */ | 74 | /** for setting the event's starting date/time with a QDateTime. */ |
75 | virtual void setDtStart(const QDateTime &dtStart); | 75 | virtual void setDtStart(const QDateTime &dtStart); |
76 | /** returns an event's starting date/time as a QDateTime. */ | 76 | /** returns an event's starting date/time as a QDateTime. */ |
77 | QDateTime dtStart() const; | 77 | QDateTime dtStart() const; |
78 | /** returns an event's starting time as a string formatted according to the | 78 | /** returns an event's starting time as a string formatted according to the |
79 | users locale settings */ | 79 | users locale settings */ |
80 | QString dtStartTimeStr() const; | 80 | QString dtStartTimeStr() const; |
81 | /** returns an event's starting date as a string formatted according to the | 81 | /** returns an event's starting date as a string formatted according to the |
82 | users locale settings */ | 82 | users locale settings */ |
83 | QString dtStartDateStr(bool shortfmt=true) const; | 83 | QString dtStartDateStr(bool shortfmt=true) const; |
84 | /** returns an event's starting date and time as a string formatted according | 84 | /** returns an event's starting date and time as a string formatted according |
85 | to the users locale settings */ | 85 | to the users locale settings */ |
86 | QString dtStartStr(bool shortfmt=true) const; | 86 | QString dtStartStr(bool shortfmt=true) const; |
87 | 87 | ||
88 | virtual void setDuration(int seconds); | 88 | virtual void setDuration(int seconds); |
89 | int duration() const; | 89 | int duration() const; |
90 | void setHasDuration(bool); | 90 | void setHasDuration(bool); |
91 | bool hasDuration() const; | 91 | bool hasDuration() const; |
92 | 92 | ||
93 | /** Return true or false depending on whether the incidence "floats," | 93 | /** Return true or false depending on whether the incidence "floats," |
94 | * i.e. has a date but no time attached to it. */ | 94 | * i.e. has a date but no time attached to it. */ |
95 | bool doesFloat() const; | 95 | bool doesFloat() const; |
96 | /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ | 96 | /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ |
97 | void setFloats(bool f); | 97 | void setFloats(bool f); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | Add Attendee to this incidence. IncidenceBase takes ownership of the | 100 | Add Attendee to this incidence. IncidenceBase takes ownership of the |
101 | Attendee object. | 101 | Attendee object. |
102 | */ | 102 | */ |
103 | void addAttendee(Attendee *a, bool doupdate=true ); | 103 | bool addAttendee(Attendee *a, bool doupdate=true ); |
104 | // void removeAttendee(Attendee *a); | 104 | // void removeAttendee(Attendee *a); |
105 | // void removeAttendee(const char *n); | 105 | // void removeAttendee(const char *n); |
106 | /** Remove all Attendees. */ | 106 | /** Remove all Attendees. */ |
107 | void clearAttendees(); | 107 | void clearAttendees(); |
108 | /** Return list of attendees. */ | 108 | /** Return list of attendees. */ |
109 | QPtrList<Attendee> attendees() const { return mAttendees; }; | 109 | QPtrList<Attendee> attendees() const { return mAttendees; }; |
110 | /** Return number of attendees. */ | 110 | /** Return number of attendees. */ |
111 | int attendeeCount() const { return mAttendees.count(); }; | 111 | int attendeeCount() const { return mAttendees.count(); }; |
112 | /** Return the Attendee with this email */ | 112 | /** Return the Attendee with this email */ |
113 | Attendee* attendeeByMail(const QString &); | 113 | Attendee* attendeeByMail(const QString &); |
114 | /** Return first Attendee with one of this emails */ | 114 | /** Return first Attendee with one of this emails */ |
115 | Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); | 115 | Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); |
116 | 116 | ||
117 | /** pilot syncronization states */ | 117 | /** pilot syncronization states */ |
118 | enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; | 118 | enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; |
119 | /** Set synchronisation satus. */ | 119 | /** Set synchronisation satus. */ |
120 | void setSyncStatus(int stat); | 120 | void setSyncStatus(int stat); |
121 | /** Return synchronisation status. */ | 121 | /** Return synchronisation status. */ |
122 | int syncStatus() const; | 122 | int syncStatus() const; |
123 | 123 | ||
124 | /** Set Pilot Id. */ | 124 | /** Set Pilot Id. */ |
125 | void setPilotId(int id); | 125 | void setPilotId(int id); |
126 | /** Return Pilot Id. */ | 126 | /** Return Pilot Id. */ |
127 | int pilotId() const; | 127 | int pilotId() const; |
128 | 128 | ||
129 | void setTempSyncStat(int id); | 129 | void setTempSyncStat(int id); |
130 | int tempSyncStat() const; | 130 | int tempSyncStat() const; |
131 | void setIDStr( const QString & ); | 131 | void setIDStr( const QString & ); |
132 | QString IDStr() const; | 132 | QString IDStr() const; |
133 | void setID( const QString &, const QString & ); | 133 | void setID( const QString &, const QString & ); |
134 | QString getID( const QString & ); | 134 | QString getID( const QString & ); |
135 | void setCsum( const QString &, const QString & ); | 135 | void setCsum( const QString &, const QString & ); |
136 | QString getCsum( const QString & ); | 136 | QString getCsum( const QString & ); |
137 | void removeID(const QString &); | 137 | void removeID(const QString &); |
138 | 138 | ||
139 | void registerObserver( Observer * ); | 139 | void registerObserver( Observer * ); |
140 | void unRegisterObserver( Observer * ); | 140 | void unRegisterObserver( Observer * ); |
141 | void updated(); | 141 | void updated(); |
142 | 142 | ||
143 | protected: | 143 | protected: |
144 | bool mReadOnly; | 144 | bool mReadOnly; |
145 | QDateTime getEvenTime( QDateTime ); | 145 | QDateTime getEvenTime( QDateTime ); |
146 | 146 | ||
147 | private: | 147 | private: |
148 | // base components | 148 | // base components |
149 | QDateTime mDtStart; | 149 | QDateTime mDtStart; |
150 | QString mOrganizer; | 150 | QString mOrganizer; |
151 | QString mUid; | 151 | QString mUid; |
152 | QDateTime mLastModified; | 152 | QDateTime mLastModified; |
153 | QPtrList<Attendee> mAttendees; | 153 | QPtrList<Attendee> mAttendees; |
154 | 154 | ||
155 | bool mFloats; | 155 | bool mFloats; |
156 | 156 | ||
157 | int mDuration; | 157 | int mDuration; |
158 | bool mHasDuration; | 158 | bool mHasDuration; |
159 | QString mExternalId; | 159 | QString mExternalId; |
160 | int mTempSyncStat; | 160 | int mTempSyncStat; |
161 | 161 | ||
162 | // PILOT SYNCHRONIZATION STUFF | 162 | // PILOT SYNCHRONIZATION STUFF |
163 | int mPilotId; // unique id for pilot sync | 163 | int mPilotId; // unique id for pilot sync |
164 | int mSyncStatus; // status (for sync) | 164 | int mSyncStatus; // status (for sync) |
165 | 165 | ||
166 | QPtrList<Observer> mObservers; | 166 | QPtrList<Observer> mObservers; |
167 | }; | 167 | }; |