summaryrefslogtreecommitdiffabout
path: root/korganizer/koeventviewer.cpp
Unidiff
Diffstat (limited to 'korganizer/koeventviewer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index de11c13..39921a0 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -114,398 +114,401 @@ void KOEventViewer::setSource(const QString& n)
114 if ( "uid:"+a->uid() == n ) { 114 if ( "uid:"+a->uid() == n ) {
115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 115 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
116 return; 116 return;
117 } 117 }
118 } 118 }
119 } 119 }
120 return; 120 return;
121 } 121 }
122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 122 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
123 // the result should now arrive through method insertAttendees 123 // the result should now arrive through method insertAttendees
124 //QString uid = "uid:"+(*it).uid(); 124 //QString uid = "uid:"+(*it).uid();
125#endif 125#endif
126 if ( n.left(6) == "mailto" ) { 126 if ( n.left(6) == "mailto" ) {
127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 127 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
128#ifndef DESKTOP_VERSION 128#ifndef DESKTOP_VERSION
129 if ( n.mid(7,3) == "ALL" ) { 129 if ( n.mid(7,3) == "ALL" ) {
130 qDebug("all "); 130 qDebug("all ");
131 mailToAttendees( true ); 131 mailToAttendees( true );
132 } else if ( n.mid(7,4) == "RSVP" ) { 132 } else if ( n.mid(7,4) == "RSVP" ) {
133 mailToAttendees( false ); 133 mailToAttendees( false );
134 qDebug("rsvp "); 134 qDebug("rsvp ");
135 } else { 135 } else {
136 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 136 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
137 e << n.mid(7); 137 e << n.mid(7);
138 } 138 }
139#endif 139#endif
140 140
141 } 141 }
142 142
143 143
144#ifndef KORG_NODCOP 144#ifndef KORG_NODCOP
145 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 145 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
146 QString tmpStr; 146 QString tmpStr;
147 if (n.startsWith("mailto:")) { 147 if (n.startsWith("mailto:")) {
148 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 148 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
149 //emit showIncidence(n); 149 //emit showIncidence(n);
150 return; 150 return;
151 } else if (n.startsWith("uid:")) { 151 } else if (n.startsWith("uid:")) {
152 DCOPClient *client = KApplication::kApplication()->dcopClient(); 152 DCOPClient *client = KApplication::kApplication()->dcopClient();
153 const QByteArray noParamData; 153 const QByteArray noParamData;
154 const QByteArray paramData; 154 const QByteArray paramData;
155 QByteArray replyData; 155 QByteArray replyData;
156 QCString replyTypeStr; 156 QCString replyTypeStr;
157#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 157#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
158 bool foundAbbrowser = PING_ABBROWSER; 158 bool foundAbbrowser = PING_ABBROWSER;
159 159
160 if (foundAbbrowser) { 160 if (foundAbbrowser) {
161 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 161 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
162 //client->send("kaddressbook","KAddressBookIface", 162 //client->send("kaddressbook","KAddressBookIface",
163 QDataStream arg(paramData, IO_WriteOnly); 163 QDataStream arg(paramData, IO_WriteOnly);
164 arg << n.mid(6); 164 arg << n.mid(6);
165 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 165 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
166 return; 166 return;
167 } else { 167 } else {
168 /* 168 /*
169 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 169 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
170 We start it without its main interface 170 We start it without its main interface
171 */ 171 */
172 KIconLoader* iconLoader = new KIconLoader(); 172 KIconLoader* iconLoader = new KIconLoader();
173 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 173 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
174 ActionManager::setStartedKAddressBook(true); 174 ActionManager::setStartedKAddressBook(true);
175 tmpStr = "kaddressbook --editor-only --uid "; 175 tmpStr = "kaddressbook --editor-only --uid ";
176 tmpStr += KProcess::quote(n.mid(6)); 176 tmpStr += KProcess::quote(n.mid(6));
177 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 177 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
178 return; 178 return;
179 } 179 }
180 } else { 180 } else {
181 //QTextBrowser::setSource(n); 181 //QTextBrowser::setSource(n);
182 } 182 }
183#endif 183#endif
184} 184}
185void KOEventViewer::mailToAttendees( bool all ) 185void KOEventViewer::mailToAttendees( bool all )
186{ 186{
187 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 187 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
188 if (attendees.count() == 0) return; 188 if (attendees.count() == 0) return;
189 QStringList nameList; 189 QStringList nameList;
190 QStringList emailList; 190 QStringList emailList;
191 QStringList uidList; 191 QStringList uidList;
192 Attendee* a; 192 Attendee* a;
193 for(a=attendees.first();a;a=attendees.next()) { 193 for(a=attendees.first();a;a=attendees.next()) {
194 if ( !all && !a->RSVP() ) continue; 194 if ( !all && !a->RSVP() ) continue;
195 if (!a->email().isEmpty()) { 195 if (!a->email().isEmpty()) {
196 nameList.append (a->name() ); 196 nameList.append (a->name() );
197 emailList.append (a->email() ); 197 emailList.append (a->email() );
198 uidList.append (a->uid() ); 198 uidList.append (a->uid() );
199 } 199 }
200 } 200 }
201 QString uid = "ComposeMailUIpick2"+mMailSubject; 201 QString uid = "ComposeMailUIpick2"+mMailSubject;
202#ifndef DESKTOP_VERSION 202#ifndef DESKTOP_VERSION
203 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 203 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
204#endif 204#endif
205 205
206} 206}
207void KOEventViewer::addTag(const QString & tag,const QString & text) 207void KOEventViewer::addTag(const QString & tag,const QString & text)
208{ 208{
209 int number=text.contains("\n"); 209 int number=text.contains("\n");
210 QString str = "<" + tag + ">"; 210 QString str = "<" + tag + ">";
211 QString tmpText=text; 211 QString tmpText=text;
212 QString tmpStr=str; 212 QString tmpStr=str;
213 if(number !=-1) 213 if(number !=-1)
214 { 214 {
215 if (number > 0) { 215 if (number > 0) {
216 int pos=0; 216 int pos=0;
217 QString tmp; 217 QString tmp;
218 for(int i=0;i<=number;i++) { 218 for(int i=0;i<=number;i++) {
219 pos=tmpText.find("\n"); 219 pos=tmpText.find("\n");
220 tmp=tmpText.left(pos); 220 tmp=tmpText.left(pos);
221 tmpText=tmpText.right(tmpText.length()-pos-1); 221 tmpText=tmpText.right(tmpText.length()-pos-1);
222 tmpStr+=tmp+"<br>"; 222 tmpStr+=tmp+"<br>";
223 } 223 }
224 } 224 }
225 else tmpStr += tmpText; 225 else tmpStr += tmpText;
226 tmpStr+="</" + tag + ">"; 226 tmpStr+="</" + tag + ">";
227 mText.append(tmpStr); 227 mText.append(tmpStr);
228 } 228 }
229 else 229 else
230 { 230 {
231 str += text + "</" + tag + ">"; 231 str += text + "</" + tag + ">";
232 mText.append(str); 232 mText.append(str);
233 } 233 }
234} 234}
235 235
236void KOEventViewer::setColorMode( int m ) 236void KOEventViewer::setColorMode( int m )
237{ 237{
238 mColorMode = m; 238 mColorMode = m;
239} 239}
240void KOEventViewer::appendEvent(Event *event, int mode ) 240void KOEventViewer::appendEvent(Event *event, int mode )
241{ 241{
242 mMailSubject = ""; 242 mMailSubject = "";
243 mCurrentIncidence = event; 243 mCurrentIncidence = event;
244 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 244 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
245 topLevelWidget()->setCaption(i18n("Event Viewer")); 245 topLevelWidget()->setCaption(i18n("Event Viewer"));
246 if ( mode == 0 ) { 246 if ( mode == 0 ) {
247 addTag("h2",event->summary()); 247 addTag("h2",event->summary());
248 } 248 }
249 else { 249 else {
250 if ( mColorMode == 1 ) { 250 if ( mColorMode == 1 ) {
251 mText +="<font color=\"#00A000\">"; 251 mText +="<font color=\"#00A000\">";
252 } 252 }
253 if ( mColorMode == 2 ) { 253 if ( mColorMode == 2 ) {
254 mText +="<font color=\"#C00000\">"; 254 mText +="<font color=\"#C00000\">";
255 } 255 }
256 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 256 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
257 if ( mode == 1 ) { 257 if ( mode == 1 ) {
258 addTag("h2",i18n( "Local: " ) +event->summary()); 258 addTag("h2",i18n( "Local: " ) +event->summary());
259 } else { 259 } else {
260 addTag("h2",i18n( "Remote: " ) +event->summary()); 260 addTag("h2",i18n( "Remote: " ) +event->summary());
261 } 261 }
262 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 262 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
263 if ( mColorMode ) 263 if ( mColorMode )
264 mText += "</font>"; 264 mText += "</font>";
265 } 265 }
266 mMailSubject += i18n( "Meeting " )+ event->summary(); 266 mMailSubject += i18n( "Meeting " )+ event->summary();
267 if (event->cancelled ()) { 267 if (event->cancelled ()) {
268 mText +="<font color=\"#B00000\">"; 268 mText +="<font color=\"#B00000\">";
269 addTag("i",i18n("This event has been cancelled!")); 269 addTag("i",i18n("This event has been cancelled!"));
270 mText.append("<br>"); 270 mText.append("<br>");
271 mText += "</font>"; 271 mText += "</font>";
272 mMailSubject += i18n("(cancelled)"); 272 mMailSubject += i18n("(cancelled)");
273 } 273 }
274 if (!event->location().isEmpty()) { 274 if (!event->location().isEmpty()) {
275 addTag("b",i18n("Location: ")); 275 addTag("b",i18n("Location: "));
276 mText.append(event->location()+"<br>"); 276 mText.append(event->location()+"<br>");
277 mMailSubject += i18n(" at ") + event->location(); 277 mMailSubject += i18n(" at ") + event->location();
278 } 278 }
279 if (event->doesFloat()) { 279 if (event->doesFloat()) {
280 if (event->isMultiDay()) { 280 if (event->isMultiDay()) {
281 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 281 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
282 .arg(event->dtStartDateStr(shortDate)) 282 .arg(event->dtStartDateStr(shortDate))
283 .arg(event->dtEndDateStr(shortDate))); 283 .arg(event->dtEndDateStr(shortDate)));
284 } else { 284 } else {
285 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 285 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
286 } 286 }
287 } else { 287 } else {
288 if (event->isMultiDay()) { 288 if (event->isMultiDay()) {
289 mText.append(i18n("<p><b>From:</b> %1</p> ") 289 mText.append(i18n("<p><b>From:</b> %1</p> ")
290 .arg(event->dtStartStr( shortDate))); 290 .arg(event->dtStartStr( shortDate)));
291 mText.append(i18n("<p><b>To:</b> %1</p>") 291 mText.append(i18n("<p><b>To:</b> %1</p>")
292 .arg(event->dtEndStr(shortDate))); 292 .arg(event->dtEndStr(shortDate)));
293 } else { 293 } else {
294 mText.append(i18n("<p><b>On:</b> %1</p> ") 294 mText.append(i18n("<p><b>On:</b> %1</p> ")
295 .arg(event->dtStartDateStr( shortDate ))); 295 .arg(event->dtStartDateStr( shortDate )));
296 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 296 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
297 .arg(event->dtStartTimeStr()) 297 .arg(event->dtStartTimeStr())
298 .arg(event->dtEndTimeStr())); 298 .arg(event->dtEndTimeStr()));
299 } 299 }
300 } 300 }
301 301
302 if (event->recurrence()->doesRecur()) { 302 if (event->recurrence()->doesRecur()) {
303 303
304 QString recurText = event->recurrence()->recurrenceText(); 304 QString recurText = event->recurrence()->recurrenceText();
305 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 305 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
306 bool last; 306 bool ok;
307 QDate start = QDate::currentDate(); 307 QDate start = QDate::currentDate();
308 QDate next; 308 QDateTime next;
309 next = event->recurrence()->getPreviousDate( start , &last ); 309 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
310 if ( !last ) { 310 if ( ok ) {
311 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
312 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 311 addTag("p",i18n("<b>Next recurrence is on:</b>") );
313 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 312 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
314 QDateTime nextdt = QDateTime( next, event->dtStart().time()); 313 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true );
315 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
316 314
317 } else { 315 } else {
318 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 316 bool last;
319 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 317 QDate nextd;
318 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
319 if ( last ) {
320 addTag("p",i18n("<b>Last recurrence was on:</b>") );
321 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
322 }
320 } 323 }
321 } else { 324 } else {
322 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 325 mMailSubject += i18n(" - " )+event->dtStartStr( true );
323 326
324 } 327 }
325 328
326 329
327 if (event->isAlarmEnabled()) { 330 if (event->isAlarmEnabled()) {
328 Alarm *alarm =event->alarms().first() ; 331 Alarm *alarm =event->alarms().first() ;
329 QDateTime t = alarm->time(); 332 QDateTime t = alarm->time();
330 int min = t.secsTo( event->dtStart() )/60; 333 int min = t.secsTo( event->dtStart() )/60;
331 QString s =i18n("( %1 min before )").arg( min ); 334 QString s =i18n("( %1 min before )").arg( min );
332 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 335 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
333 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 336 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
334 //addTag("p",s); 337 //addTag("p",s);
335 } 338 }
336 339
337 addTag("b",i18n("Access: ")); 340 addTag("b",i18n("Access: "));
338 mText.append(event->secrecyStr()+"<br>"); 341 mText.append(event->secrecyStr()+"<br>");
339 if (!event->description().isEmpty()) { 342 if (!event->description().isEmpty()) {
340 addTag("p",i18n("<b>Details: </b>")); 343 addTag("p",i18n("<b>Details: </b>"));
341 addTag("p",event->description()); 344 addTag("p",event->description());
342 } 345 }
343 346
344 formatCategories(event); 347 formatCategories(event);
345 348
346 formatReadOnly(event); 349 formatReadOnly(event);
347 formatAttendees(event); 350 formatAttendees(event);
348 351
349 setText(mText); 352 setText(mText);
350 //QWhatsThis::add(this,mText); 353 //QWhatsThis::add(this,mText);
351 354
352} 355}
353 356
354void KOEventViewer::appendTodo(Todo *event, int mode ) 357void KOEventViewer::appendTodo(Todo *event, int mode )
355{ 358{
356 mMailSubject = ""; 359 mMailSubject = "";
357 mCurrentIncidence = event; 360 mCurrentIncidence = event;
358 topLevelWidget()->setCaption(i18n("Todo Viewer")); 361 topLevelWidget()->setCaption(i18n("Todo Viewer"));
359 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 362 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
360 if (mode == 0 ) 363 if (mode == 0 )
361 addTag("h2",event->summary()); 364 addTag("h2",event->summary());
362 else { 365 else {
363 if ( mColorMode == 1 ) { 366 if ( mColorMode == 1 ) {
364 mText +="<font color=\"#00A000\">"; 367 mText +="<font color=\"#00A000\">";
365 } 368 }
366 if ( mColorMode == 2 ) { 369 if ( mColorMode == 2 ) {
367 mText +="<font color=\"#B00000\">"; 370 mText +="<font color=\"#B00000\">";
368 } 371 }
369 if ( mode == 1 ) { 372 if ( mode == 1 ) {
370 addTag("h2",i18n( "Local: " ) +event->summary()); 373 addTag("h2",i18n( "Local: " ) +event->summary());
371 } else { 374 } else {
372 addTag("h2",i18n( "Remote: " ) +event->summary()); 375 addTag("h2",i18n( "Remote: " ) +event->summary());
373 } 376 }
374 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 377 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
375 if ( mColorMode ) 378 if ( mColorMode )
376 mText += "</font>"; 379 mText += "</font>";
377 } 380 }
378 mMailSubject += i18n( "Todo " )+ event->summary(); 381 mMailSubject += i18n( "Todo " )+ event->summary();
379 382
380 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 383 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
381 mText +="<font color=\"#B00000\">"; 384 mText +="<font color=\"#B00000\">";
382 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); 385 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) );
383 mText += "</font>"; 386 mText += "</font>";
384 } else { 387 } else {
385 mText.append(i18n("<p><i>%1 % completed</i></p>") 388 mText.append(i18n("<p><i>%1 % completed</i></p>")
386 .arg(event->percentComplete())); 389 .arg(event->percentComplete()));
387 } 390 }
388 391
389 if (event->cancelled ()) { 392 if (event->cancelled ()) {
390 mText +="<font color=\"#B00000\">"; 393 mText +="<font color=\"#B00000\">";
391 addTag("i",i18n("This todo has been cancelled!")); 394 addTag("i",i18n("This todo has been cancelled!"));
392 mText.append("<br>"); 395 mText.append("<br>");
393 mText += "</font>"; 396 mText += "</font>";
394 mMailSubject += i18n("(cancelled)"); 397 mMailSubject += i18n("(cancelled)");
395 } 398 }
396 399
397 if (!event->location().isEmpty()) { 400 if (!event->location().isEmpty()) {
398 addTag("b",i18n("Location: ")); 401 addTag("b",i18n("Location: "));
399 mText.append(event->location()+"<br>"); 402 mText.append(event->location()+"<br>");
400 mMailSubject += i18n(" at ") + event->location(); 403 mMailSubject += i18n(" at ") + event->location();
401 } 404 }
402 if (event->hasStartDate()) { 405 if (event->hasStartDate()) {
403 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 406 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
404 } 407 }
405 if (event->hasDueDate()) { 408 if (event->hasDueDate()) {
406 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 409 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
407 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 410 mMailSubject += i18n(" - " )+event->dtDueStr( true );
408 } 411 }
409 addTag("b",i18n("Access: ")); 412 addTag("b",i18n("Access: "));
410 mText.append(event->secrecyStr()+"<br>"); 413 mText.append(event->secrecyStr()+"<br>");
411 if (!event->description().isEmpty()) { 414 if (!event->description().isEmpty()) {
412 addTag("p",i18n("<b>Details: </b>")); 415 addTag("p",i18n("<b>Details: </b>"));
413 addTag("p",event->description()); 416 addTag("p",event->description());
414 } 417 }
415 418
416 formatCategories(event); 419 formatCategories(event);
417 420
418 mText.append(i18n("<p><b>Priority:</b> %2</p>") 421 mText.append(i18n("<p><b>Priority:</b> %2</p>")
419 .arg(QString::number(event->priority()))); 422 .arg(QString::number(event->priority())));
420 423
421 formatReadOnly(event); 424 formatReadOnly(event);
422 formatAttendees(event); 425 formatAttendees(event);
423 if ( event->relatedTo() ) { 426 if ( event->relatedTo() ) {
424 addTag("b",i18n("Parent todo:<br>")); 427 addTag("b",i18n("Parent todo:<br>"));
425 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 428 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
426 } 429 }
427 QPtrList<Incidence> Relations = event->relations(); 430 QPtrList<Incidence> Relations = event->relations();
428 Incidence *to; 431 Incidence *to;
429 if ( Relations.first() ) 432 if ( Relations.first() )
430 addTag("b",i18n("Sub todos:<br>")); 433 addTag("b",i18n("Sub todos:<br>"));
431 for (to=Relations.first();to;to=Relations.next()) { 434 for (to=Relations.first();to;to=Relations.next()) {
432 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 435 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
433 436
434 } 437 }
435 setText(mText); 438 setText(mText);
436} 439}
437 440
438void KOEventViewer::formatCategories(Incidence *event) 441void KOEventViewer::formatCategories(Incidence *event)
439{ 442{
440 if (!event->categoriesStr().isEmpty()) { 443 if (!event->categoriesStr().isEmpty()) {
441 if (event->categories().count() == 1) { 444 if (event->categories().count() == 1) {
442 addTag("h3",i18n("Category")); 445 addTag("h3",i18n("Category"));
443 } else { 446 } else {
444 addTag("h3",i18n("Categories")); 447 addTag("h3",i18n("Categories"));
445 } 448 }
446 addTag("p",event->categoriesStr()); 449 addTag("p",event->categoriesStr());
447 } 450 }
448} 451}
449void KOEventViewer::formatAttendees(Incidence *event) 452void KOEventViewer::formatAttendees(Incidence *event)
450{ 453{
451 QPtrList<Attendee> attendees = event->attendees(); 454 QPtrList<Attendee> attendees = event->attendees();
452 if (attendees.count()) { 455 if (attendees.count()) {
453 456
454 457
455 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 458 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
456 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 459 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
457 addTag("h3",i18n("Organizer")); 460 addTag("h3",i18n("Organizer"));
458 mText.append("<ul><li>"); 461 mText.append("<ul><li>");
459#ifndef KORG_NOKABC 462#ifndef KORG_NOKABC
460 463
461#ifdef DESKTOP_VERSION 464#ifdef DESKTOP_VERSION
462 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 465 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
463 KABC::Addressee::List addressList; 466 KABC::Addressee::List addressList;
464 addressList = add_book->findByEmail(event->organizer()); 467 addressList = add_book->findByEmail(event->organizer());
465 KABC::Addressee o = addressList.first(); 468 KABC::Addressee o = addressList.first();
466 if (!o.isEmpty() && addressList.size()<2) { 469 if (!o.isEmpty() && addressList.size()<2) {
467 mText += "<a href=\"uid:" + o.uid() + "\">"; 470 mText += "<a href=\"uid:" + o.uid() + "\">";
468 mText += o.formattedName(); 471 mText += o.formattedName();
469 mText += "</a>\n"; 472 mText += "</a>\n";
470 } else { 473 } else {
471 mText.append(event->organizer()); 474 mText.append(event->organizer());
472 } 475 }
473#else //DESKTOP_VERSION 476#else //DESKTOP_VERSION
474 mText += "<a href=\"uid:organizer\">"; 477 mText += "<a href=\"uid:organizer\">";
475 mText += event->organizer(); 478 mText += event->organizer();
476 mText += "</a>\n"; 479 mText += "</a>\n";
477#endif //DESKTOP_VERSION 480#endif //DESKTOP_VERSION
478 481
479 482
480#else 483#else
481 mText.append(event->organizer()); 484 mText.append(event->organizer());
482#endif 485#endif
483 486
484 if (iconPath) { 487 if (iconPath) {
485 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 488 mText += " <a href=\"mailto:" + event->organizer() + "\">";
486 mText += "<IMG src=\"" + iconPath + "\">"; 489 mText += "<IMG src=\"" + iconPath + "\">";
487 mText += "</a>\n"; 490 mText += "</a>\n";
488 } 491 }
489 mText.append("</li></ul>"); 492 mText.append("</li></ul>");
490 493
491 addTag("h3",i18n("Attendees")); 494 addTag("h3",i18n("Attendees"));
492 Attendee *a; 495 Attendee *a;
493 mText.append("<ul>"); 496 mText.append("<ul>");
494 int a_count = 0; 497 int a_count = 0;
495 int a_count_nr = 0; 498 int a_count_nr = 0;
496 499
497 for(a=attendees.first();a;a=attendees.next()) { 500 for(a=attendees.first();a;a=attendees.next()) {
498#ifndef KORG_NOKABC 501#ifndef KORG_NOKABC
499#ifdef DESKTOP_VERSION 502#ifdef DESKTOP_VERSION
500 if (a->name().isEmpty()) { 503 if (a->name().isEmpty()) {
501 addressList = add_book->findByEmail(a->email()); 504 addressList = add_book->findByEmail(a->email());
502 KABC::Addressee o = addressList.first(); 505 KABC::Addressee o = addressList.first();
503 if (!o.isEmpty() && addressList.size()<2) { 506 if (!o.isEmpty() && addressList.size()<2) {
504 mText += "<a href=\"uid:" + o.uid() + "\">"; 507 mText += "<a href=\"uid:" + o.uid() + "\">";
505 mText += o.formattedName(); 508 mText += o.formattedName();
506 mText += "</a>\n"; 509 mText += "</a>\n";
507 } else { 510 } else {
508 mText += "<li>"; 511 mText += "<li>";
509 mText.append(a->email()); 512 mText.append(a->email());
510 mText += "\n"; 513 mText += "\n";
511 } 514 }