-rw-r--r-- | libkcal/kincidenceformatter.cpp | 18 | ||||
-rw-r--r-- | libkcal/todo.cpp | 5 | ||||
-rw-r--r-- | libkcal/todo.h | 2 |
3 files changed, 13 insertions, 12 deletions
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index c52f2b3..6d07d4c 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -122,122 +122,122 @@ void KIncidenceFormatter::setEvent(Event *event) | |||
122 | if (event->isAlarmEnabled()) { | 122 | if (event->isAlarmEnabled()) { |
123 | Alarm *alarm =event->alarms().first() ; | 123 | Alarm *alarm =event->alarms().first() ; |
124 | QDateTime t = alarm->time(); | 124 | QDateTime t = alarm->time(); |
125 | int min = t.secsTo( event->dtStart() )/60; | 125 | int min = t.secsTo( event->dtStart() )/60; |
126 | QString s =i18n("(%1 min before)").arg( min ); | 126 | QString s =i18n("(%1 min before)").arg( min ); |
127 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); | 127 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); |
128 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 128 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
129 | //addTag("p",s); | 129 | //addTag("p",s); |
130 | } | 130 | } |
131 | 131 | ||
132 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 132 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
133 | // mText.append(event->secrecyStr()+"<br>"); | 133 | // mText.append(event->secrecyStr()+"<br>"); |
134 | formatCategories(event); | 134 | formatCategories(event); |
135 | if (!event->description().isEmpty()) { | 135 | if (!event->description().isEmpty()) { |
136 | addTag("p",i18n("<b>Details: </b>")); | 136 | addTag("p",i18n("<b>Details: </b>")); |
137 | addTag("p",event->description()); | 137 | addTag("p",event->description()); |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | formatReadOnly(event); | 141 | formatReadOnly(event); |
142 | formatAttendees(event); | 142 | formatAttendees(event); |
143 | 143 | ||
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | void KIncidenceFormatter::setTodo(Todo *event ) | 147 | void KIncidenceFormatter::setTodo(Todo *event ) |
148 | { | 148 | { |
149 | int mode = 0; | 149 | int mode = 0; |
150 | mCurrentIncidence = event; | 150 | mCurrentIncidence = event; |
151 | bool shortDate = true; | 151 | bool shortDate = true; |
152 | if (mode == 0 ) | 152 | if (mode == 0 ) |
153 | addTag("h3",event->summary()); | 153 | addTag("h3",event->summary()); |
154 | else { | 154 | else { |
155 | if ( mColorMode == 1 ) { | 155 | if ( mColorMode == 1 ) { |
156 | mText +="<font color=\"#00A000\">"; | 156 | mText +="<font color=\"#00A000\">"; |
157 | } | 157 | } |
158 | if ( mColorMode == 2 ) { | 158 | if ( mColorMode == 2 ) { |
159 | mText +="<font color=\"#B00000\">"; | 159 | mText +="<font color=\"#B00000\">"; |
160 | } | 160 | } |
161 | if ( mode == 1 ) { | 161 | if ( mode == 1 ) { |
162 | addTag("h2",i18n( "Local: " ) +event->summary()); | 162 | addTag("h2",i18n( "Local: " ) +event->summary()); |
163 | } else { | 163 | } else { |
164 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 164 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
165 | } | 165 | } |
166 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 166 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
167 | if ( mColorMode ) | 167 | if ( mColorMode ) |
168 | mText += "</font>"; | 168 | mText += "</font>"; |
169 | } | 169 | } |
170 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | ||
171 | mText +="<font color=\"#B00000\">"; | ||
172 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); | ||
173 | mText += "</font>"; | ||
174 | } else { | ||
175 | mText.append(i18n("<p><i>%1 % completed</i></p>") | ||
176 | .arg(event->percentComplete())); | ||
177 | } | ||
170 | if (event->cancelled ()) { | 178 | if (event->cancelled ()) { |
171 | mText +="<font color=\"#B00000\">"; | 179 | mText +="<font color=\"#B00000\">"; |
172 | addTag("i",i18n("This todo has been cancelled!")); | 180 | addTag("i",i18n("This todo has been cancelled!")); |
173 | mText.append("<br>"); | 181 | mText.append("<br>"); |
174 | mText += "</font>"; | 182 | mText += "</font>"; |
175 | } | 183 | } |
176 | 184 | ||
177 | if (!event->location().isEmpty()) { | 185 | if (!event->location().isEmpty()) { |
178 | addTag("b",i18n("Location: ")); | 186 | addTag("b",i18n("Location: ")); |
179 | mText.append(event->location()+"<br>"); | 187 | mText.append(event->location()+"<br>"); |
180 | } | 188 | } |
181 | if (event->hasDueDate()) { | 189 | if (event->hasDueDate()) { |
182 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); | 190 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); |
183 | } | 191 | } |
184 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 192 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
185 | .arg(QString::number(event->priority()))); | 193 | .arg(QString::number(event->priority()))); |
186 | 194 | ||
187 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 195 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
188 | mText.append(i18n("<p><i>Completed on %1</i></p>") | ||
189 | .arg( event->completedStr() )); | ||
190 | } else { | ||
191 | mText.append(i18n("<p><i>%1 % completed</i></p>") | ||
192 | .arg(event->percentComplete())); | ||
193 | } | ||
194 | |||
195 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | ||
196 | formatCategories(event); | 196 | formatCategories(event); |
197 | if (!event->description().isEmpty()) { | 197 | if (!event->description().isEmpty()) { |
198 | addTag("p",i18n("<b>Details: </b>")); | 198 | addTag("p",i18n("<b>Details: </b>")); |
199 | addTag("p",event->description()); | 199 | addTag("p",event->description()); |
200 | } | 200 | } |
201 | 201 | ||
202 | 202 | ||
203 | 203 | ||
204 | formatReadOnly(event); | 204 | formatReadOnly(event); |
205 | formatAttendees(event); | 205 | formatAttendees(event); |
206 | 206 | ||
207 | } | 207 | } |
208 | 208 | ||
209 | void KIncidenceFormatter::setJournal(Journal* ) | 209 | void KIncidenceFormatter::setJournal(Journal* ) |
210 | { | 210 | { |
211 | 211 | ||
212 | } | 212 | } |
213 | 213 | ||
214 | void KIncidenceFormatter::formatCategories(Incidence *event) | 214 | void KIncidenceFormatter::formatCategories(Incidence *event) |
215 | { | 215 | { |
216 | if (!event->categoriesStr().isEmpty()) { | 216 | if (!event->categoriesStr().isEmpty()) { |
217 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); | 217 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); |
218 | //mText.append(event->categoriesStr()); | 218 | //mText.append(event->categoriesStr()); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 221 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) |
222 | { | 222 | { |
223 | int number=text.contains("\n"); | 223 | int number=text.contains("\n"); |
224 | QString str = "<" + tag + ">"; | 224 | QString str = "<" + tag + ">"; |
225 | QString tmpText=text; | 225 | QString tmpText=text; |
226 | QString tmpStr=str; | 226 | QString tmpStr=str; |
227 | if(number !=-1) | 227 | if(number !=-1) |
228 | { | 228 | { |
229 | if (number > 0) { | 229 | if (number > 0) { |
230 | int pos=0; | 230 | int pos=0; |
231 | QString tmp; | 231 | QString tmp; |
232 | for(int i=0;i<=number;i++) { | 232 | for(int i=0;i<=number;i++) { |
233 | pos=tmpText.find("\n"); | 233 | pos=tmpText.find("\n"); |
234 | tmp=tmpText.left(pos); | 234 | tmp=tmpText.left(pos); |
235 | tmpText=tmpText.right(tmpText.length()-pos-1); | 235 | tmpText=tmpText.right(tmpText.length()-pos-1); |
236 | tmpStr+=tmp+"<br>"; | 236 | tmpStr+=tmp+"<br>"; |
237 | } | 237 | } |
238 | } | 238 | } |
239 | else tmpStr += tmpText; | 239 | else tmpStr += tmpText; |
240 | tmpStr+="</" + tag + ">"; | 240 | tmpStr+="</" + tag + ">"; |
241 | mText.append(tmpStr); | 241 | mText.append(tmpStr); |
242 | } | 242 | } |
243 | else | 243 | else |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 7362bdf..7d04793 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -255,103 +255,104 @@ QString Todo::statusStr() const | |||
255 | break; | 255 | break; |
256 | case ACCEPTED: | 256 | case ACCEPTED: |
257 | return QString("ACCEPTED"); | 257 | return QString("ACCEPTED"); |
258 | break; | 258 | break; |
259 | case SENT: | 259 | case SENT: |
260 | return QString("SENT"); | 260 | return QString("SENT"); |
261 | break; | 261 | break; |
262 | case TENTATIVE: | 262 | case TENTATIVE: |
263 | return QString("TENTATIVE"); | 263 | return QString("TENTATIVE"); |
264 | break; | 264 | break; |
265 | case CONFIRMED: | 265 | case CONFIRMED: |
266 | return QString("CONFIRMED"); | 266 | return QString("CONFIRMED"); |
267 | break; | 267 | break; |
268 | case DECLINED: | 268 | case DECLINED: |
269 | return QString("DECLINED"); | 269 | return QString("DECLINED"); |
270 | break; | 270 | break; |
271 | case COMPLETED: | 271 | case COMPLETED: |
272 | return QString("COMPLETED"); | 272 | return QString("COMPLETED"); |
273 | break; | 273 | break; |
274 | case DELEGATED: | 274 | case DELEGATED: |
275 | return QString("DELEGATED"); | 275 | return QString("DELEGATED"); |
276 | break; | 276 | break; |
277 | } | 277 | } |
278 | return QString(""); | 278 | return QString(""); |
279 | } | 279 | } |
280 | #endif | 280 | #endif |
281 | 281 | ||
282 | bool Todo::isCompleted() const | 282 | bool Todo::isCompleted() const |
283 | { | 283 | { |
284 | if (mPercentComplete == 100) return true; | 284 | if (mPercentComplete == 100) return true; |
285 | else return false; | 285 | else return false; |
286 | } | 286 | } |
287 | 287 | ||
288 | void Todo::setCompleted(bool completed) | 288 | void Todo::setCompleted(bool completed) |
289 | { | 289 | { |
290 | if (completed) mPercentComplete = 100; | 290 | if (completed) mPercentComplete = 100; |
291 | else { | 291 | else { |
292 | mPercentComplete = 0; | 292 | mPercentComplete = 0; |
293 | mHasCompletedDate = false; | 293 | mHasCompletedDate = false; |
294 | } | 294 | } |
295 | updated(); | 295 | updated(); |
296 | } | 296 | } |
297 | 297 | ||
298 | QDateTime Todo::completed() const | 298 | QDateTime Todo::completed() const |
299 | { | 299 | { |
300 | return mCompleted; | 300 | return mCompleted; |
301 | } | 301 | } |
302 | 302 | ||
303 | QString Todo::completedStr() const | 303 | QString Todo::completedStr( bool shortF ) const |
304 | { | 304 | { |
305 | return KGlobal::locale()->formatDateTime(mCompleted); | 305 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
306 | } | 306 | } |
307 | 307 | ||
308 | void Todo::setCompleted(const QDateTime &completed) | 308 | void Todo::setCompleted(const QDateTime &completed) |
309 | { | 309 | { |
310 | qDebug("Todo::setCompleted "); | ||
310 | mHasCompletedDate = true; | 311 | mHasCompletedDate = true; |
311 | mPercentComplete = 100; | 312 | mPercentComplete = 100; |
312 | mCompleted = getEvenTime(completed); | 313 | mCompleted = getEvenTime(completed); |
313 | updated(); | 314 | updated(); |
314 | } | 315 | } |
315 | 316 | ||
316 | bool Todo::hasCompletedDate() const | 317 | bool Todo::hasCompletedDate() const |
317 | { | 318 | { |
318 | return mHasCompletedDate; | 319 | return mHasCompletedDate; |
319 | } | 320 | } |
320 | 321 | ||
321 | int Todo::percentComplete() const | 322 | int Todo::percentComplete() const |
322 | { | 323 | { |
323 | return mPercentComplete; | 324 | return mPercentComplete; |
324 | } | 325 | } |
325 | 326 | ||
326 | void Todo::setPercentComplete(int v) | 327 | void Todo::setPercentComplete(int v) |
327 | { | 328 | { |
328 | mPercentComplete = v; | 329 | mPercentComplete = v; |
329 | if ( v != 100 ) | 330 | if ( v != 100 ) |
330 | mHasCompletedDate = false; | 331 | mHasCompletedDate = false; |
331 | updated(); | 332 | updated(); |
332 | } | 333 | } |
333 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | 334 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const |
334 | { | 335 | { |
335 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { | 336 | if ( isCompleted() || ! hasDueDate() || cancelled() ) { |
336 | *ok = false; | 337 | *ok = false; |
337 | return QDateTime (); | 338 | return QDateTime (); |
338 | } | 339 | } |
339 | QDateTime incidenceStart; | 340 | QDateTime incidenceStart; |
340 | incidenceStart = dtDue(); | 341 | incidenceStart = dtDue(); |
341 | bool enabled = false; | 342 | bool enabled = false; |
342 | Alarm* alarm; | 343 | Alarm* alarm; |
343 | int off; | 344 | int off; |
344 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 345 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
345 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 346 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
346 | // *ok = false; | 347 | // *ok = false; |
347 | // return incidenceStart; | 348 | // return incidenceStart; |
348 | // } | 349 | // } |
349 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 350 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
350 | if (alarm->enabled()) { | 351 | if (alarm->enabled()) { |
351 | if ( alarm->hasTime () ) { | 352 | if ( alarm->hasTime () ) { |
352 | if ( alarm->time() < alarmStart ) { | 353 | if ( alarm->time() < alarmStart ) { |
353 | alarmStart = alarm->time(); | 354 | alarmStart = alarm->time(); |
354 | enabled = true; | 355 | enabled = true; |
355 | off = alarmStart.secsTo( incidenceStart ); | 356 | off = alarmStart.secsTo( incidenceStart ); |
356 | } | 357 | } |
357 | 358 | ||
diff --git a/libkcal/todo.h b/libkcal/todo.h index 0f22c59..41f5841 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -48,75 +48,75 @@ class Todo : public Incidence | |||
48 | /** returns an event's Due date/time as a QDateTime. */ | 48 | /** returns an event's Due date/time as a QDateTime. */ |
49 | QDateTime dtDue() const; | 49 | QDateTime dtDue() const; |
50 | /** returns an event's due time as a string formatted according to the | 50 | /** returns an event's due time as a string formatted according to the |
51 | users locale settings */ | 51 | users locale settings */ |
52 | QString dtDueTimeStr() const; | 52 | QString dtDueTimeStr() const; |
53 | /** returns an event's due date as a string formatted according to the | 53 | /** returns an event's due date as a string formatted according to the |
54 | users locale settings */ | 54 | users locale settings */ |
55 | QString dtDueDateStr(bool shortfmt=true) const; | 55 | QString dtDueDateStr(bool shortfmt=true) const; |
56 | /** returns an event's due date and time as a string formatted according | 56 | /** returns an event's due date and time as a string formatted according |
57 | to the users locale settings */ | 57 | to the users locale settings */ |
58 | QString dtDueStr(bool shortfmt=true) const; | 58 | QString dtDueStr(bool shortfmt=true) const; |
59 | 59 | ||
60 | /** returns TRUE or FALSE depending on whether the todo has a due date */ | 60 | /** returns TRUE or FALSE depending on whether the todo has a due date */ |
61 | bool hasDueDate() const; | 61 | bool hasDueDate() const; |
62 | /** sets the event's hasDueDate value. */ | 62 | /** sets the event's hasDueDate value. */ |
63 | void setHasDueDate(bool f); | 63 | void setHasDueDate(bool f); |
64 | 64 | ||
65 | 65 | ||
66 | /** sets the event's status to the string specified. The string | 66 | /** sets the event's status to the string specified. The string |
67 | * must be a recognized value for the status field, i.e. a string | 67 | * must be a recognized value for the status field, i.e. a string |
68 | * equivalent of the possible status enumerations previously described. */ | 68 | * equivalent of the possible status enumerations previously described. */ |
69 | // void setStatus(const QString &statStr); | 69 | // void setStatus(const QString &statStr); |
70 | /** sets the event's status to the value specified. See the enumeration | 70 | /** sets the event's status to the value specified. See the enumeration |
71 | * above for possible values. */ | 71 | * above for possible values. */ |
72 | // void setStatus(int); | 72 | // void setStatus(int); |
73 | /** return the event's status. */ | 73 | /** return the event's status. */ |
74 | // int status() const; | 74 | // int status() const; |
75 | /** return the event's status in string format. */ | 75 | /** return the event's status in string format. */ |
76 | // QString statusStr() const; | 76 | // QString statusStr() const; |
77 | 77 | ||
78 | /** return, if this todo is completed */ | 78 | /** return, if this todo is completed */ |
79 | bool isCompleted() const; | 79 | bool isCompleted() const; |
80 | /** set completed state of this todo */ | 80 | /** set completed state of this todo */ |
81 | void setCompleted(bool); | 81 | void setCompleted(bool); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | Return how many percent of the task are completed. Returns a value | 84 | Return how many percent of the task are completed. Returns a value |
85 | between 0 and 100. | 85 | between 0 and 100. |
86 | */ | 86 | */ |
87 | int percentComplete() const; | 87 | int percentComplete() const; |
88 | /** | 88 | /** |
89 | Set how many percent of the task are completed. Valid values are in the | 89 | Set how many percent of the task are completed. Valid values are in the |
90 | range from 0 to 100. | 90 | range from 0 to 100. |
91 | */ | 91 | */ |
92 | void setPercentComplete(int); | 92 | void setPercentComplete(int); |
93 | 93 | ||
94 | /** return date and time when todo was completed */ | 94 | /** return date and time when todo was completed */ |
95 | QDateTime completed() const; | 95 | QDateTime completed() const; |
96 | QString completedStr() const; | 96 | QString completedStr(bool shortF = true) const; |
97 | /** set date and time of completion */ | 97 | /** set date and time of completion */ |
98 | void setCompleted(const QDateTime &completed); | 98 | void setCompleted(const QDateTime &completed); |
99 | 99 | ||
100 | /** Return true, if todo has a date associated with completion */ | 100 | /** Return true, if todo has a date associated with completion */ |
101 | bool hasCompletedDate() const; | 101 | bool hasCompletedDate() const; |
102 | bool contains ( Todo*); | 102 | bool contains ( Todo*); |
103 | 103 | ||
104 | private: | 104 | private: |
105 | bool accept(Visitor &v) { return v.visit(this); } | 105 | bool accept(Visitor &v) { return v.visit(this); } |
106 | 106 | ||
107 | QDateTime mDtDue; // due date of todo | 107 | QDateTime mDtDue; // due date of todo |
108 | 108 | ||
109 | bool mHasDueDate; // if todo has associated due date | 109 | bool mHasDueDate; // if todo has associated due date |
110 | 110 | ||
111 | // int mStatus; // confirmed/delegated/tentative/etc | 111 | // int mStatus; // confirmed/delegated/tentative/etc |
112 | 112 | ||
113 | QDateTime mCompleted; | 113 | QDateTime mCompleted; |
114 | bool mHasCompletedDate; | 114 | bool mHasCompletedDate; |
115 | 115 | ||
116 | int mPercentComplete; | 116 | int mPercentComplete; |
117 | }; | 117 | }; |
118 | 118 | ||
119 | bool operator==( const Todo&, const Todo& ); | 119 | bool operator==( const Todo&, const Todo& ); |
120 | } | 120 | } |
121 | 121 | ||
122 | #endif | 122 | #endif |