summaryrefslogtreecommitdiffabout
path: root/korganizer/koeventviewer.cpp
Unidiff
Diffstat (limited to 'korganizer/koeventviewer.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp50
1 files changed, 42 insertions, 8 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 1f69700..0866939 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -29,101 +29,122 @@
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <libkdepim/addresseeview.h> 38#include <libkdepim/addresseeview.h>
39#include <kabc/stdaddressbook.h> 39#include <kabc/stdaddressbook.h>
40 40
41#ifndef KORG_NODCOP 41#ifndef KORG_NODCOP
42#include <dcopclient.h> 42#include <dcopclient.h>
43#include "korganizer.h" 43#include "korganizer.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "actionmanager.h" 45#include "actionmanager.h"
46#endif 46#endif
47 47
48#include "koeventviewer.h" 48#include "koeventviewer.h"
49#ifndef KORG_NOKABC 49#ifndef KORG_NOKABC
50#include <kabc/stdaddressbook.h> 50#include <kabc/stdaddressbook.h>
51#define size count 51#define size count
52#endif 52#endif
53#ifndef DESKTOP_VERSION 53
54#ifdef DESKTOP_VERSION
55#include <kabc/addresseedialog.h>
56#else //DESKTOP_VERSION
57#include <externalapphandler.h>
54#include <qtopia/qcopenvelope_qws.h> 58#include <qtopia/qcopenvelope_qws.h>
55#endif 59#endif //DESKTOP_VERSION
56 60
57KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 61KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
58 : QTextBrowser(parent,name) 62 : QTextBrowser(parent,name)
59{ 63{
60 mSyncMode = false; 64 mSyncMode = false;
61 mColorMode = 0; 65 mColorMode = 0;
62} 66}
63 67
64KOEventViewer::~KOEventViewer() 68KOEventViewer::~KOEventViewer()
65{ 69{
66} 70}
67 71
68void KOEventViewer::setSource(const QString& n) 72void KOEventViewer::setSource(const QString& n)
69{ 73{
70 74
71 if ( n.left(3) == "uid" ) { 75 if ( n.left(3) == "uid" )
76#ifdef DESKTOP_VERSION
77 {
72 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
73 KABC::AddressBook::Iterator it; 79 KABC::AddressBook::Iterator it;
74 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
75 // LR I do not understand, why the uid string is different on zaurus and desktop 81 // LR I do not understand, why the uid string is different on zaurus and desktop
76#ifdef DESKTOP_VERSION
77 QString uid = "uid://"+(*it).uid(); 82 QString uid = "uid://"+(*it).uid();
78#else 83
79 QString uid = "uid:"+(*it).uid();
80#endif
81 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
82 if (n == uid ) { 85 if (n == uid ) {
83 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
84 QDialog dia( this,"dia123", true ); 87 QDialog dia( this,"dia123", true );
85 dia.setCaption( i18n("Details of attendee") ); 88 dia.setCaption( i18n("Details of attendee") );
86 QVBoxLayout lay ( &dia ); 89 QVBoxLayout lay ( &dia );
87 KPIM::AddresseeView av ( &dia ); 90 KPIM::AddresseeView av ( &dia );
88 av.setAddressee( (*it) ); 91 av.setAddressee( (*it) );
89 lay.addWidget( &av ); 92 lay.addWidget( &av );
90 if ( QApplication::desktop()->width() < 480 ) 93 if ( QApplication::desktop()->width() < 480 )
91 dia.resize( 220, 240); 94 dia.resize( 220, 240);
92 else { 95 else {
93 dia.resize( 400,400); 96 dia.resize( 400,400);
94 97
95 } 98 }
96 dia.exec(); 99 dia.exec();
97 break; 100 break;
98 } 101 }
99 } 102 }
100 return; 103 return;
101 } 104 }
105#else
106 {
107 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
108 if (attendees.count()) {
109 Attendee *a;
110 for(a=attendees.first();a;a=attendees.next()) {
111 if ( "uid:"+a->uid() == n ) {
112 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), "");
113 return;
114 }
115 }
116 }
117 return;
118 }
119 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
120 // the result should now arrive through method insertAttendees
121 //QString uid = "uid:"+(*it).uid();
122#endif
102 if ( n.left(6) == "mailto" ) { 123 if ( n.left(6) == "mailto" ) {
103 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 124 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
104#ifndef DESKTOP_VERSION 125#ifndef DESKTOP_VERSION
105 QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)" ); 126 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
106 e << n.mid(7); 127 e << n.mid(7);
107#endif 128#endif
108 129
109 } 130 }
110 131
111 132
112#ifndef KORG_NODCOP 133#ifndef KORG_NODCOP
113 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 134 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
114 QString tmpStr; 135 QString tmpStr;
115 if (n.startsWith("mailto:")) { 136 if (n.startsWith("mailto:")) {
116 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 137 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
117 //emit showIncidence(n); 138 //emit showIncidence(n);
118 return; 139 return;
119 } else if (n.startsWith("uid:")) { 140 } else if (n.startsWith("uid:")) {
120 DCOPClient *client = KApplication::kApplication()->dcopClient(); 141 DCOPClient *client = KApplication::kApplication()->dcopClient();
121 const QByteArray noParamData; 142 const QByteArray noParamData;
122 const QByteArray paramData; 143 const QByteArray paramData;
123 QByteArray replyData; 144 QByteArray replyData;
124 QCString replyTypeStr; 145 QCString replyTypeStr;
125#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 146#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
126 bool foundAbbrowser = PING_ABBROWSER; 147 bool foundAbbrowser = PING_ABBROWSER;
127 148
128 if (foundAbbrowser) { 149 if (foundAbbrowser) {
129 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 150 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
@@ -362,93 +383,106 @@ void KOEventViewer::appendTodo(Todo *event, int mode )
362} 383}
363 384
364void KOEventViewer::formatCategories(Incidence *event) 385void KOEventViewer::formatCategories(Incidence *event)
365{ 386{
366 if (!event->categoriesStr().isEmpty()) { 387 if (!event->categoriesStr().isEmpty()) {
367 if (event->categories().count() == 1) { 388 if (event->categories().count() == 1) {
368 addTag("h3",i18n("Category")); 389 addTag("h3",i18n("Category"));
369 } else { 390 } else {
370 addTag("h3",i18n("Categories")); 391 addTag("h3",i18n("Categories"));
371 } 392 }
372 addTag("p",event->categoriesStr()); 393 addTag("p",event->categoriesStr());
373 } 394 }
374} 395}
375void KOEventViewer::formatAttendees(Incidence *event) 396void KOEventViewer::formatAttendees(Incidence *event)
376{ 397{
377 QPtrList<Attendee> attendees = event->attendees(); 398 QPtrList<Attendee> attendees = event->attendees();
378 if (attendees.count()) { 399 if (attendees.count()) {
379 400
380 401
381 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 402 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
382 addTag("h3",i18n("Organizer")); 403 addTag("h3",i18n("Organizer"));
383 mText.append("<ul><li>"); 404 mText.append("<ul><li>");
384#ifndef KORG_NOKABC 405#ifndef KORG_NOKABC
385 406
407#ifdef DESKTOP_VERSION
386 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 408 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
387 KABC::Addressee::List addressList; 409 KABC::Addressee::List addressList;
388 addressList = add_book->findByEmail(event->organizer()); 410 addressList = add_book->findByEmail(event->organizer());
389 KABC::Addressee o = addressList.first(); 411 KABC::Addressee o = addressList.first();
390 if (!o.isEmpty() && addressList.size()<2) { 412 if (!o.isEmpty() && addressList.size()<2) {
391 mText += "<a href=\"uid:" + o.uid() + "\">"; 413 mText += "<a href=\"uid:" + o.uid() + "\">";
392 mText += o.formattedName(); 414 mText += o.formattedName();
393 mText += "</a>\n"; 415 mText += "</a>\n";
394 } else { 416 } else {
395 mText.append(event->organizer()); 417 mText.append(event->organizer());
396 } 418 }
419#else //DESKTOP_VERSION
420 mText.append(event->organizer());
421#endif //DESKTOP_VERSION
422
423
397#else 424#else
398 mText.append(event->organizer()); 425 mText.append(event->organizer());
399#endif 426#endif
400 427
401 if (iconPath) { 428 if (iconPath) {
402 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 429 mText += " <a href=\"mailto:" + event->organizer() + "\">";
403 mText += "<IMG src=\"" + iconPath + "\">"; 430 mText += "<IMG src=\"" + iconPath + "\">";
404 mText += "</a>\n"; 431 mText += "</a>\n";
405 } 432 }
406 mText.append("</li></ul>"); 433 mText.append("</li></ul>");
407 434
408 addTag("h3",i18n("Attendees")); 435 addTag("h3",i18n("Attendees"));
409 Attendee *a; 436 Attendee *a;
410 mText.append("<ul>"); 437 mText.append("<ul>");
411 for(a=attendees.first();a;a=attendees.next()) { 438 for(a=attendees.first();a;a=attendees.next()) {
412#ifndef KORG_NOKABC 439#ifndef KORG_NOKABC
440#ifdef DESKTOP_VERSION
413 if (a->name().isEmpty()) { 441 if (a->name().isEmpty()) {
414 addressList = add_book->findByEmail(a->email()); 442 addressList = add_book->findByEmail(a->email());
415 KABC::Addressee o = addressList.first(); 443 KABC::Addressee o = addressList.first();
416 if (!o.isEmpty() && addressList.size()<2) { 444 if (!o.isEmpty() && addressList.size()<2) {
417 mText += "<a href=\"uid:" + o.uid() + "\">"; 445 mText += "<a href=\"uid:" + o.uid() + "\">";
418 mText += o.formattedName(); 446 mText += o.formattedName();
419 mText += "</a>\n"; 447 mText += "</a>\n";
420 } else { 448 } else {
421 mText += "<li>"; 449 mText += "<li>";
422 mText.append(a->email()); 450 mText.append(a->email());
423 mText += "\n"; 451 mText += "\n";
424 } 452 }
425 } else { 453 } else {
426 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 454 mText += "<li><a href=\"uid:" + a->uid() + "\">";
427 if (!a->name().isEmpty()) mText += a->name(); 455 if (!a->name().isEmpty()) mText += a->name();
428 else mText += a->email(); 456 else mText += a->email();
429 mText += "</a>\n"; 457 mText += "</a>\n";
430 } 458 }
459#else //DESKTOP_VERSION
460 mText += "<li><a href=\"uid:" + a->uid() + "\">";
461 if (!a->name().isEmpty()) mText += a->name();
462 else mText += a->email();
463 mText += "</a>\n";
464#endif //DESKTOP_VERSION
431#else 465#else
432 //qDebug("nokabc "); 466 //qDebug("nokabc ");
433 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 467 mText += "<li><a href=\"uid:" + a->uid() + "\">";
434 if (!a->name().isEmpty()) mText += a->name(); 468 if (!a->name().isEmpty()) mText += a->name();
435 else mText += a->email(); 469 else mText += a->email();
436 mText += "</a>\n"; 470 mText += "</a>\n";
437#endif 471#endif
438 472
439 473
440 if (!a->email().isEmpty()) { 474 if (!a->email().isEmpty()) {
441 if (iconPath) { 475 if (iconPath) {
442 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 476 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
443 mText += "<IMG src=\"" + iconPath + "\">"; 477 mText += "<IMG src=\"" + iconPath + "\">";
444 mText += "</a>\n"; 478 mText += "</a>\n";
445 } 479 }
446 } 480 }
447 if (a->status() != Attendee::NeedsAction ) 481 if (a->status() != Attendee::NeedsAction )
448 mText +="[" + a->statusStr() + "] "; 482 mText +="[" + a->statusStr() + "] ";
449 if (a->role() == Attendee::Chair ) 483 if (a->role() == Attendee::Chair )
450 mText +="(" + a->roleStr().left(1) + ".)"; 484 mText +="(" + a->roleStr().left(1) + ".)";
451 } 485 }
452 mText.append("</li></ul>"); 486 mText.append("</li></ul>");
453 } 487 }
454 488