Diffstat (limited to 'libkcal/kincidenceformatter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 733b897..bce68b0 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -1,38 +1,40 @@ | |||
1 | #include "kincidenceformatter.h" | 1 | #include "kincidenceformatter.h" |
2 | #include <kstaticdeleter.h> | 2 | #include <kstaticdeleter.h> |
3 | #include <kglobal.h> | 3 | #include <kglobal.h> |
4 | #include <klocale.h> | 4 | #include <klocale.h> |
5 | #ifdef DEKTOP_VERSION | 5 | #ifdef DEKTOP_VERSION |
6 | #include <kabc/stdaddressbook.h> | 6 | #include <kabc/stdaddressbook.h> |
7 | //Added by qt3to4: | ||
8 | #include <Q3PtrList> | ||
7 | #define size count | 9 | #define size count |
8 | #endif | 10 | #endif |
9 | 11 | ||
10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; | 12 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; |
11 | static KStaticDeleter<KIncidenceFormatter> insd; | 13 | static KStaticDeleter<KIncidenceFormatter> insd; |
12 | 14 | ||
13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) | 15 | QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) |
14 | { | 16 | { |
15 | // #ifndef QT_NO_INPUTDIALOG | 17 | // #ifndef QT_NO_INPUTDIALOG |
16 | // return QInputDialog::getItem( caption, label, items, current, editable ); | 18 | // return QInputDialog::getItem( caption, label, items, current, editable ); |
17 | // #else | 19 | // #else |
18 | // return QString::null; | 20 | // return QString::null; |
19 | // #endif | 21 | // #endif |
20 | mDetails = details; | 22 | mDetails = details; |
21 | mCreated = created ; | 23 | mCreated = created ; |
22 | mModified = modified; | 24 | mModified = modified; |
23 | mText = ""; | 25 | mText = ""; |
24 | if ( inc->typeID() == eventID ) | 26 | if ( inc->typeID() == eventID ) |
25 | setEvent((Event *) inc ); | 27 | setEvent((Event *) inc ); |
26 | else if ( inc->typeID() == todoID ) | 28 | else if ( inc->typeID() == todoID ) |
27 | setTodo((Todo *) inc ); | 29 | setTodo((Todo *) inc ); |
28 | return mText; | 30 | return mText; |
29 | } | 31 | } |
30 | 32 | ||
31 | KIncidenceFormatter* KIncidenceFormatter::instance() | 33 | KIncidenceFormatter* KIncidenceFormatter::instance() |
32 | { | 34 | { |
33 | if (!mInstance) { | 35 | if (!mInstance) { |
34 | mInstance = insd.setObject(new KIncidenceFormatter()); | 36 | mInstance = insd.setObject(new KIncidenceFormatter()); |
35 | } | 37 | } |
36 | return mInstance; | 38 | return mInstance; |
37 | } | 39 | } |
38 | KIncidenceFormatter::~KIncidenceFormatter() | 40 | KIncidenceFormatter::~KIncidenceFormatter() |
@@ -281,157 +283,157 @@ void KIncidenceFormatter::setTodo(Todo *event ) | |||
281 | } | 283 | } |
282 | if ( mModified ) { | 284 | if ( mModified ) { |
283 | #ifdef DESKTOP_VERSION | 285 | #ifdef DESKTOP_VERSION |
284 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 286 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
285 | #else | 287 | #else |
286 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 288 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
287 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 289 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
288 | #endif | 290 | #endif |
289 | 291 | ||
290 | } | 292 | } |
291 | if ( mDetails ) { | 293 | if ( mDetails ) { |
292 | if (!event->description().isEmpty()) { | 294 | if (!event->description().isEmpty()) { |
293 | addTag("p",i18n("<b>Details: </b>")); | 295 | addTag("p",i18n("<b>Details: </b>")); |
294 | addTag("p",deTag(event->description())); | 296 | addTag("p",deTag(event->description())); |
295 | } | 297 | } |
296 | } | 298 | } |
297 | } | 299 | } |
298 | 300 | ||
299 | void KIncidenceFormatter::setJournal(Journal* ) | 301 | void KIncidenceFormatter::setJournal(Journal* ) |
300 | { | 302 | { |
301 | 303 | ||
302 | } | 304 | } |
303 | 305 | ||
304 | void KIncidenceFormatter::formatCategories(Incidence *event) | 306 | void KIncidenceFormatter::formatCategories(Incidence *event) |
305 | { | 307 | { |
306 | if (!event->categoriesStr().isEmpty()) { | 308 | if (!event->categoriesStr().isEmpty()) { |
307 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); | 309 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); |
308 | //mText.append(event->categoriesStr()); | 310 | //mText.append(event->categoriesStr()); |
309 | } | 311 | } |
310 | } | 312 | } |
311 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 313 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) |
312 | { | 314 | { |
313 | int number=text.contains("\n"); | 315 | int number=text.count("\n"); |
314 | QString str = "<" + tag + ">"; | 316 | QString str = "<" + tag + ">"; |
315 | QString tmpText=text; | 317 | QString tmpText=text; |
316 | QString tmpStr=str; | 318 | QString tmpStr=str; |
317 | if(number !=-1) | 319 | if(number !=-1) |
318 | { | 320 | { |
319 | if (number > 0) { | 321 | if (number > 0) { |
320 | int pos=0; | 322 | int pos=0; |
321 | QString tmp; | 323 | QString tmp; |
322 | for(int i=0;i<=number;i++) { | 324 | for(int i=0;i<=number;i++) { |
323 | pos=tmpText.find("\n"); | 325 | pos=tmpText.find("\n"); |
324 | tmp=tmpText.left(pos); | 326 | tmp=tmpText.left(pos); |
325 | tmpText=tmpText.right(tmpText.length()-pos-1); | 327 | tmpText=tmpText.right(tmpText.length()-pos-1); |
326 | tmpStr+=tmp+"<br>"; | 328 | tmpStr+=tmp+"<br>"; |
327 | } | 329 | } |
328 | } | 330 | } |
329 | else tmpStr += tmpText; | 331 | else tmpStr += tmpText; |
330 | tmpStr+="</" + tag + ">"; | 332 | tmpStr+="</" + tag + ">"; |
331 | mText.append(tmpStr); | 333 | mText.append(tmpStr); |
332 | } | 334 | } |
333 | else | 335 | else |
334 | { | 336 | { |
335 | str += text + "</" + tag + ">"; | 337 | str += text + "</" + tag + ">"; |
336 | mText.append(str); | 338 | mText.append(str); |
337 | } | 339 | } |
338 | } | 340 | } |
339 | 341 | ||
340 | void KIncidenceFormatter::formatAttendees(Incidence *event) | 342 | void KIncidenceFormatter::formatAttendees(Incidence *event) |
341 | { | 343 | { |
342 | QPtrList<Attendee> attendees = event->attendees(); | 344 | Q3PtrList<Attendee> attendees = event->attendees(); |
343 | if (attendees.count()) { | 345 | if (attendees.count()) { |
344 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 346 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
345 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 347 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
346 | addTag("h3",i18n("Organizer")); | 348 | addTag("h3",i18n("Organizer")); |
347 | mText.append("<ul><li>"); | 349 | mText.append("<ul><li>"); |
348 | #if 0 | 350 | #if 0 |
349 | //ndef KORG_NOKABC | 351 | //ndef KORG_NOKABC |
350 | 352 | ||
351 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 353 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
352 | KABC::Addressee::List addressList; | 354 | KABC::Addressee::List addressList; |
353 | addressList = add_book->findByEmail(event->organizer()); | 355 | addressList = add_book->findByEmail(event->organizer()); |
354 | KABC::Addressee o = addressList.first(); | 356 | KABC::Addressee o = addressList.first(); |
355 | if (!o.isEmpty() && addressList.size()<2) { | 357 | if (!o.isEmpty() && addressList.size()<2) { |
356 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 358 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
357 | mText += o.formattedName(); | 359 | mText += o.formattedName(); |
358 | mText += "</a>\n"; | 360 | mText += "</a>\n"; |
359 | } else { | 361 | } else { |
360 | mText.append(event->organizer()); | 362 | mText.append(event->organizer()); |
361 | } | 363 | } |
362 | #else | 364 | #else |
363 | mText.append(event->organizer()); | 365 | mText.append(event->organizer()); |
364 | #endif | 366 | #endif |
365 | if (iconPath) { | 367 | if (!iconPath.isEmpty()) { |
366 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 368 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
367 | mText += "<IMG src=\"" + iconPath + "\">"; | 369 | mText += "<IMG src=\"" + iconPath + "\">"; |
368 | mText += "</a>\n"; | 370 | mText += "</a>\n"; |
369 | } | 371 | } |
370 | mText.append("</li></ul>"); | 372 | mText.append("</li></ul>"); |
371 | 373 | ||
372 | addTag("h3",i18n("Attendees")); | 374 | addTag("h3",i18n("Attendees")); |
373 | Attendee *a; | 375 | Attendee *a; |
374 | mText.append("<ul>"); | 376 | mText.append("<ul>"); |
375 | for(a=attendees.first();a;a=attendees.next()) { | 377 | for(a=attendees.first();a;a=attendees.next()) { |
376 | #if 0 | 378 | #if 0 |
377 | //ndef KORG_NOKABC | 379 | //ndef KORG_NOKABC |
378 | if (a->name().isEmpty()) { | 380 | if (a->name().isEmpty()) { |
379 | addressList = add_book->findByEmail(a->email()); | 381 | addressList = add_book->findByEmail(a->email()); |
380 | KABC::Addressee o = addressList.first(); | 382 | KABC::Addressee o = addressList.first(); |
381 | if (!o.isEmpty() && addressList.size()<2) { | 383 | if (!o.isEmpty() && addressList.size()<2) { |
382 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 384 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
383 | mText += o.formattedName(); | 385 | mText += o.formattedName(); |
384 | mText += "</a>\n"; | 386 | mText += "</a>\n"; |
385 | } else { | 387 | } else { |
386 | mText += "<li>"; | 388 | mText += "<li>"; |
387 | mText.append(a->email()); | 389 | mText.append(a->email()); |
388 | mText += "\n"; | 390 | mText += "\n"; |
389 | } | 391 | } |
390 | } else { | 392 | } else { |
391 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 393 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
392 | if (!a->name().isEmpty()) mText += a->name(); | 394 | if (!a->name().isEmpty()) mText += a->name(); |
393 | else mText += a->email(); | 395 | else mText += a->email(); |
394 | mText += "</a>\n"; | 396 | mText += "</a>\n"; |
395 | } | 397 | } |
396 | #else | 398 | #else |
397 | //qDebug("nokabc "); | 399 | //qDebug("nokabc "); |
398 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 400 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
399 | if (!a->name().isEmpty()) mText += a->name(); | 401 | if (!a->name().isEmpty()) mText += a->name(); |
400 | else mText += a->email(); | 402 | else mText += a->email(); |
401 | mText += "</a>\n"; | 403 | mText += "</a>\n"; |
402 | #endif | 404 | #endif |
403 | 405 | ||
404 | if (!a->email().isEmpty()) { | 406 | if (!a->email().isEmpty()) { |
405 | if (iconPath) { | 407 | if (!iconPath.isEmpty()) { |
406 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; | 408 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; |
407 | if ( a->RSVP() ) | 409 | if ( a->RSVP() ) |
408 | mText += "<IMG src=\"" + iconPath + "\">"; | 410 | mText += "<IMG src=\"" + iconPath + "\">"; |
409 | else | 411 | else |
410 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 412 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
411 | mText += "</a>\n"; | 413 | mText += "</a>\n"; |
412 | } | 414 | } |
413 | } | 415 | } |
414 | if (a->status() != Attendee::NeedsAction ) | 416 | if (a->status() != Attendee::NeedsAction ) |
415 | mText +="[" + a->statusStr() + "] "; | 417 | mText +="[" + a->statusStr() + "] "; |
416 | if (a->role() == Attendee::Chair ) | 418 | if (a->role() == Attendee::Chair ) |
417 | mText +="(" + a->roleStr().left(1) + ".)"; | 419 | mText +="(" + a->roleStr().left(1) + ".)"; |
418 | } | 420 | } |
419 | mText.append("</li></ul>"); | 421 | mText.append("</li></ul>"); |
420 | } | 422 | } |
421 | } | 423 | } |
422 | 424 | ||
423 | void KIncidenceFormatter::formatReadOnly(Incidence *event) | 425 | void KIncidenceFormatter::formatReadOnly(Incidence *event) |
424 | { | 426 | { |
425 | if (event->isReadOnly()) { | 427 | if (event->isReadOnly()) { |
426 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 428 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
427 | } | 429 | } |
428 | } | 430 | } |
429 | QString KIncidenceFormatter::deTag(QString text) | 431 | QString KIncidenceFormatter::deTag(QString text) |
430 | { | 432 | { |
431 | #if QT_VERSION >= 0x030000 | 433 | #if QT_VERSION >= 0x030000 |
432 | text.replace( '<' , "<" ); | 434 | text.replace( '<' , "<" ); |
433 | text.replace( '>' , ">" ); | 435 | text.replace( '>' , ">" ); |
434 | #else | 436 | #else |
435 | if ( text.find ('<') >= 0 ) { | 437 | if ( text.find ('<') >= 0 ) { |
436 | text.replace( QRegExp("<") , "<" ); | 438 | text.replace( QRegExp("<") , "<" ); |
437 | } | 439 | } |