summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-01-30 01:41:12 (UTC)
committer zautrix <zautrix>2005-01-30 01:41:12 (UTC)
commit949c6e28c83668176fd9c29e12668322c6ae627f (patch) (unidiff)
treef5b21c9fe6d9f1906a7bca6899b44bcf359f2cc6 /libkcal
parenta8fae20ad7bcb59df9a603c88accf3a10401c2f9 (diff)
downloadkdepimpi-949c6e28c83668176fd9c29e12668322c6ae627f.zip
kdepimpi-949c6e28c83668176fd9c29e12668322c6ae627f.tar.gz
kdepimpi-949c6e28c83668176fd9c29e12668322c6ae627f.tar.bz2
bugs
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/kincidenceformatter.cpp16
-rw-r--r--libkcal/todo.cpp7
2 files changed, 19 insertions, 4 deletions
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 2c45f21..c52f2b3 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -138,191 +138,201 @@ void KIncidenceFormatter::setEvent(Event *event)
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
147void KIncidenceFormatter::setTodo(Todo *event ) 147void 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->cancelled ()) { 170 if (event->cancelled ()) {
171 mText +="<font color=\"#B00000\">"; 171 mText +="<font color=\"#B00000\">";
172 addTag("i",i18n("This todo has been cancelled!")); 172 addTag("i",i18n("This todo has been cancelled!"));
173 mText.append("<br>"); 173 mText.append("<br>");
174 mText += "</font>"; 174 mText += "</font>";
175 } 175 }
176 176
177 if (!event->location().isEmpty()) { 177 if (!event->location().isEmpty()) {
178 addTag("b",i18n("Location: ")); 178 addTag("b",i18n("Location: "));
179 mText.append(event->location()+"<br>"); 179 mText.append(event->location()+"<br>");
180 } 180 }
181 if (event->hasDueDate()) { 181 if (event->hasDueDate()) {
182 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); 182 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
183 } 183 }
184 mText.append(i18n("<p><b>Priority:</b> %2</p>") 184 mText.append(i18n("<p><b>Priority:</b> %2</p>")
185 .arg(QString::number(event->priority()))); 185 .arg(QString::number(event->priority())));
186 186
187 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
188 mText.append(i18n("<p><i>Completed on %1</i></p>")
189 .arg( event->completedStr() ));
190 } else {
187 mText.append(i18n("<p><i>%1 % completed</i></p>") 191 mText.append(i18n("<p><i>%1 % completed</i></p>")
188 .arg(event->percentComplete())); 192 .arg(event->percentComplete()));
193 }
194
189 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 195 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
190 formatCategories(event); 196 formatCategories(event);
191 if (!event->description().isEmpty()) { 197 if (!event->description().isEmpty()) {
192 addTag("p",i18n("<b>Details: </b>")); 198 addTag("p",i18n("<b>Details: </b>"));
193 addTag("p",event->description()); 199 addTag("p",event->description());
194 } 200 }
195 201
196 202
197 203
198 formatReadOnly(event); 204 formatReadOnly(event);
199 formatAttendees(event); 205 formatAttendees(event);
200 206
201} 207}
202 208
203void KIncidenceFormatter::setJournal(Journal* ) 209void KIncidenceFormatter::setJournal(Journal* )
204{ 210{
205 211
206} 212}
207 213
208void KIncidenceFormatter::formatCategories(Incidence *event) 214void KIncidenceFormatter::formatCategories(Incidence *event)
209{ 215{
210 if (!event->categoriesStr().isEmpty()) { 216 if (!event->categoriesStr().isEmpty()) {
211 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); 217 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() );
212 //mText.append(event->categoriesStr()); 218 //mText.append(event->categoriesStr());
213 } 219 }
214} 220}
215void KIncidenceFormatter::addTag(const QString & tag,const QString & text) 221void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
216{ 222{
217 int number=text.contains("\n"); 223 int number=text.contains("\n");
218 QString str = "<" + tag + ">"; 224 QString str = "<" + tag + ">";
219 QString tmpText=text; 225 QString tmpText=text;
220 QString tmpStr=str; 226 QString tmpStr=str;
221 if(number !=-1) 227 if(number !=-1)
222 { 228 {
223 if (number > 0) { 229 if (number > 0) {
224 int pos=0; 230 int pos=0;
225 QString tmp; 231 QString tmp;
226 for(int i=0;i<=number;i++) { 232 for(int i=0;i<=number;i++) {
227 pos=tmpText.find("\n"); 233 pos=tmpText.find("\n");
228 tmp=tmpText.left(pos); 234 tmp=tmpText.left(pos);
229 tmpText=tmpText.right(tmpText.length()-pos-1); 235 tmpText=tmpText.right(tmpText.length()-pos-1);
230 tmpStr+=tmp+"<br>"; 236 tmpStr+=tmp+"<br>";
231 } 237 }
232 } 238 }
233 else tmpStr += tmpText; 239 else tmpStr += tmpText;
234 tmpStr+="</" + tag + ">"; 240 tmpStr+="</" + tag + ">";
235 mText.append(tmpStr); 241 mText.append(tmpStr);
236 } 242 }
237 else 243 else
238 { 244 {
239 str += text + "</" + tag + ">"; 245 str += text + "</" + tag + ">";
240 mText.append(str); 246 mText.append(str);
241 } 247 }
242} 248}
243 249
244void KIncidenceFormatter::formatAttendees(Incidence *event) 250void KIncidenceFormatter::formatAttendees(Incidence *event)
245{ 251{
246 QPtrList<Attendee> attendees = event->attendees(); 252 QPtrList<Attendee> attendees = event->attendees();
247 if (attendees.count()) { 253 if (attendees.count()) {
248 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 254 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
255 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
249 addTag("h3",i18n("Organizer")); 256 addTag("h3",i18n("Organizer"));
250 mText.append("<ul><li>"); 257 mText.append("<ul><li>");
251#if 0 258#if 0
252 //ndef KORG_NOKABC 259 //ndef KORG_NOKABC
253 260
254 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 261 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
255 KABC::Addressee::List addressList; 262 KABC::Addressee::List addressList;
256 addressList = add_book->findByEmail(event->organizer()); 263 addressList = add_book->findByEmail(event->organizer());
257 KABC::Addressee o = addressList.first(); 264 KABC::Addressee o = addressList.first();
258 if (!o.isEmpty() && addressList.size()<2) { 265 if (!o.isEmpty() && addressList.size()<2) {
259 mText += "<a href=\"uid:" + o.uid() + "\">"; 266 mText += "<a href=\"uid:" + o.uid() + "\">";
260 mText += o.formattedName(); 267 mText += o.formattedName();
261 mText += "</a>\n"; 268 mText += "</a>\n";
262 } else { 269 } else {
263 mText.append(event->organizer()); 270 mText.append(event->organizer());
264 } 271 }
265#else 272#else
266 mText.append(event->organizer()); 273 mText.append(event->organizer());
267#endif 274#endif
268 if (iconPath) { 275 if (iconPath) {
269 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 276 mText += " <a href=\"mailto:" + event->organizer() + "\">";
270 mText += "<IMG src=\"" + iconPath + "\">"; 277 mText += "<IMG src=\"" + iconPath + "\">";
271 mText += "</a>\n"; 278 mText += "</a>\n";
272 } 279 }
273 mText.append("</li></ul>"); 280 mText.append("</li></ul>");
274 281
275 addTag("h3",i18n("Attendees")); 282 addTag("h3",i18n("Attendees"));
276 Attendee *a; 283 Attendee *a;
277 mText.append("<ul>"); 284 mText.append("<ul>");
278 for(a=attendees.first();a;a=attendees.next()) { 285 for(a=attendees.first();a;a=attendees.next()) {
279#if 0 286#if 0
280//ndef KORG_NOKABC 287//ndef KORG_NOKABC
281 if (a->name().isEmpty()) { 288 if (a->name().isEmpty()) {
282 addressList = add_book->findByEmail(a->email()); 289 addressList = add_book->findByEmail(a->email());
283 KABC::Addressee o = addressList.first(); 290 KABC::Addressee o = addressList.first();
284 if (!o.isEmpty() && addressList.size()<2) { 291 if (!o.isEmpty() && addressList.size()<2) {
285 mText += "<a href=\"uid:" + o.uid() + "\">"; 292 mText += "<a href=\"uid:" + o.uid() + "\">";
286 mText += o.formattedName(); 293 mText += o.formattedName();
287 mText += "</a>\n"; 294 mText += "</a>\n";
288 } else { 295 } else {
289 mText += "<li>"; 296 mText += "<li>";
290 mText.append(a->email()); 297 mText.append(a->email());
291 mText += "\n"; 298 mText += "\n";
292 } 299 }
293 } else { 300 } else {
294 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 301 mText += "<li><a href=\"uid:" + a->uid() + "\">";
295 if (!a->name().isEmpty()) mText += a->name(); 302 if (!a->name().isEmpty()) mText += a->name();
296 else mText += a->email(); 303 else mText += a->email();
297 mText += "</a>\n"; 304 mText += "</a>\n";
298 } 305 }
299#else 306#else
300 //qDebug("nokabc "); 307 //qDebug("nokabc ");
301 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 308 mText += "<li><a href=\"uid:" + a->uid() + "\">";
302 if (!a->name().isEmpty()) mText += a->name(); 309 if (!a->name().isEmpty()) mText += a->name();
303 else mText += a->email(); 310 else mText += a->email();
304 mText += "</a>\n"; 311 mText += "</a>\n";
305#endif 312#endif
306 313
307 if (!a->email().isEmpty()) { 314 if (!a->email().isEmpty()) {
308 if (iconPath) { 315 if (iconPath) {
309 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 316 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
310 mText += "<IMG src=\"" + iconPath + "\">"; 317 if ( a->RSVP() )
318 mText += "<IMG src=\"" + iconPath + "\">";
319 else
320 mText += "<IMG src=\"" + NOiconPath + "\">";
311 mText += "</a>\n"; 321 mText += "</a>\n";
312 } 322 }
313 } 323 }
314 if (a->status() != Attendee::NeedsAction ) 324 if (a->status() != Attendee::NeedsAction )
315 mText +="[" + a->statusStr() + "] "; 325 mText +="[" + a->statusStr() + "] ";
316 if (a->role() == Attendee::Chair ) 326 if (a->role() == Attendee::Chair )
317 mText +="(" + a->roleStr().left(1) + ".)"; 327 mText +="(" + a->roleStr().left(1) + ".)";
318 } 328 }
319 mText.append("</li></ul>"); 329 mText.append("</li></ul>");
320 } 330 }
321} 331}
322 332
323void KIncidenceFormatter::formatReadOnly(Incidence *event) 333void KIncidenceFormatter::formatReadOnly(Incidence *event)
324{ 334{
325 if (event->isReadOnly()) { 335 if (event->isReadOnly()) {
326 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 336 addTag("p","<em>(" + i18n("read-only") + ")</em>");
327 } 337 }
328} 338}
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 3d2de61..7362bdf 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -243,131 +243,136 @@ void Todo::setStatus(int status)
243} 243}
244 244
245int Todo::status() const 245int Todo::status() const
246{ 246{
247 return mStatus; 247 return mStatus;
248} 248}
249 249
250QString Todo::statusStr() const 250QString Todo::statusStr() const
251{ 251{
252 switch(mStatus) { 252 switch(mStatus) {
253 case NEEDS_ACTION: 253 case NEEDS_ACTION:
254 return QString("NEEDS ACTION"); 254 return QString("NEEDS ACTION");
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
282bool Todo::isCompleted() const 282bool 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
288void Todo::setCompleted(bool completed) 288void Todo::setCompleted(bool completed)
289{ 289{
290 if (completed) mPercentComplete = 100; 290 if (completed) mPercentComplete = 100;
291 else mPercentComplete = 0; 291 else {
292 mPercentComplete = 0;
293 mHasCompletedDate = false;
294 }
292 updated(); 295 updated();
293} 296}
294 297
295QDateTime Todo::completed() const 298QDateTime Todo::completed() const
296{ 299{
297 return mCompleted; 300 return mCompleted;
298} 301}
299 302
300QString Todo::completedStr() const 303QString Todo::completedStr() const
301{ 304{
302 return KGlobal::locale()->formatDateTime(mCompleted); 305 return KGlobal::locale()->formatDateTime(mCompleted);
303} 306}
304 307
305void Todo::setCompleted(const QDateTime &completed) 308void Todo::setCompleted(const QDateTime &completed)
306{ 309{
307 mHasCompletedDate = true; 310 mHasCompletedDate = true;
308 mPercentComplete = 100; 311 mPercentComplete = 100;
309 mCompleted = getEvenTime(completed); 312 mCompleted = getEvenTime(completed);
310 updated(); 313 updated();
311} 314}
312 315
313bool Todo::hasCompletedDate() const 316bool Todo::hasCompletedDate() const
314{ 317{
315 return mHasCompletedDate; 318 return mHasCompletedDate;
316} 319}
317 320
318int Todo::percentComplete() const 321int Todo::percentComplete() const
319{ 322{
320 return mPercentComplete; 323 return mPercentComplete;
321} 324}
322 325
323void Todo::setPercentComplete(int v) 326void Todo::setPercentComplete(int v)
324{ 327{
325 mPercentComplete = v; 328 mPercentComplete = v;
329 if ( v != 100 )
330 mHasCompletedDate = false;
326 updated(); 331 updated();
327} 332}
328QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const 333QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
329{ 334{
330 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 335 if ( isCompleted() || ! hasDueDate() || cancelled() ) {
331 *ok = false; 336 *ok = false;
332 return QDateTime (); 337 return QDateTime ();
333 } 338 }
334 QDateTime incidenceStart; 339 QDateTime incidenceStart;
335 incidenceStart = dtDue(); 340 incidenceStart = dtDue();
336 bool enabled = false; 341 bool enabled = false;
337 Alarm* alarm; 342 Alarm* alarm;
338 int off; 343 int off;
339 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 344 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
340 // if ( QDateTime::currentDateTime() > incidenceStart ){ 345 // if ( QDateTime::currentDateTime() > incidenceStart ){
341// *ok = false; 346// *ok = false;
342// return incidenceStart; 347// return incidenceStart;
343// } 348// }
344 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 349 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
345 if (alarm->enabled()) { 350 if (alarm->enabled()) {
346 if ( alarm->hasTime () ) { 351 if ( alarm->hasTime () ) {
347 if ( alarm->time() < alarmStart ) { 352 if ( alarm->time() < alarmStart ) {
348 alarmStart = alarm->time(); 353 alarmStart = alarm->time();
349 enabled = true; 354 enabled = true;
350 off = alarmStart.secsTo( incidenceStart ); 355 off = alarmStart.secsTo( incidenceStart );
351 } 356 }
352 357
353 } else { 358 } else {
354 int secs = alarm->startOffset().asSeconds(); 359 int secs = alarm->startOffset().asSeconds();
355 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 360 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
356 alarmStart = incidenceStart.addSecs( secs ); 361 alarmStart = incidenceStart.addSecs( secs );
357 enabled = true; 362 enabled = true;
358 off = -secs; 363 off = -secs;
359 } 364 }
360 } 365 }
361 } 366 }
362 } 367 }
363 if ( enabled ) { 368 if ( enabled ) {
364 if ( alarmStart > QDateTime::currentDateTime() ) { 369 if ( alarmStart > QDateTime::currentDateTime() ) {
365 *ok = true; 370 *ok = true;
366 * offset = off; 371 * offset = off;
367 return alarmStart; 372 return alarmStart;
368 } 373 }
369 } 374 }
370 *ok = false; 375 *ok = false;
371 return QDateTime (); 376 return QDateTime ();
372 377
373} 378}