summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 2f538c4..d34e6a9 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,575 +1,581 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
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 53
54#ifdef DESKTOP_VERSION 54#ifdef DESKTOP_VERSION
55#include <kabc/addresseedialog.h> 55#include <kabc/addresseedialog.h>
56#else //DESKTOP_VERSION 56#else //DESKTOP_VERSION
57#include <externalapphandler.h> 57#include <externalapphandler.h>
58#include <qtopia/qcopenvelope_qws.h> 58#include <qtopia/qcopenvelope_qws.h>
59#endif //DESKTOP_VERSION 59#endif //DESKTOP_VERSION
60 60
61KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 61KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
62 : QTextBrowser(parent,name) 62 : QTextBrowser(parent,name)
63{ 63{
64 mSyncMode = false; 64 mSyncMode = false;
65 mColorMode = 0; 65 mColorMode = 0;
66} 66}
67 67
68KOEventViewer::~KOEventViewer() 68KOEventViewer::~KOEventViewer()
69{ 69{
70} 70}
71 71
72void KOEventViewer::setSource(const QString& n) 72void KOEventViewer::setSource(const QString& n)
73{ 73{
74 74
75 if ( n.left(3) == "uid" ) 75 if ( n.left(3) == "uid" )
76#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
77 { 77 {
78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 78 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
79 KABC::AddressBook::Iterator it; 79 KABC::AddressBook::Iterator it;
80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 80 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
81 // 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
82 QString uid = "uid://"+(*it).uid(); 82 QString uid = "uid://"+(*it).uid();
83 83
84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 84 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
85 if (n == uid ) { 85 if (n == uid ) {
86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 86 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
87 QDialog dia( this,"dia123", true ); 87 QDialog dia( this,"dia123", true );
88 dia.setCaption( i18n("Details of attendee") ); 88 dia.setCaption( i18n("Details of attendee") );
89 QVBoxLayout lay ( &dia ); 89 QVBoxLayout lay ( &dia );
90 KPIM::AddresseeView av ( &dia ); 90 KPIM::AddresseeView av ( &dia );
91 av.setAddressee( (*it) ); 91 av.setAddressee( (*it) );
92 lay.addWidget( &av ); 92 lay.addWidget( &av );
93 if ( QApplication::desktop()->width() < 480 ) 93 if ( QApplication::desktop()->width() < 480 )
94 dia.resize( 220, 240); 94 dia.resize( 220, 240);
95 else { 95 else {
96 dia.resize( 400,400); 96 dia.resize( 400,400);
97 97
98 } 98 }
99 dia.exec(); 99 dia.exec();
100 break; 100 break;
101 } 101 }
102 } 102 }
103 return; 103 return;
104 } 104 }
105#else 105#else
106 { 106 {
107 if ( "uid:organizer" == n ) {
108 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
109 return;
110 }
107 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 111 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
108 if (attendees.count()) { 112 if (attendees.count()) {
109 Attendee *a; 113 Attendee *a;
110 for(a=attendees.first();a;a=attendees.next()) { 114 for(a=attendees.first();a;a=attendees.next()) {
111 if ( "uid:"+a->uid() == n ) { 115 if ( "uid:"+a->uid() == n ) {
112 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 116 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
113 return; 117 return;
114 } 118 }
115 } 119 }
116 } 120 }
117 return; 121 return;
118 } 122 }
119 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 123 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
120 // the result should now arrive through method insertAttendees 124 // the result should now arrive through method insertAttendees
121 //QString uid = "uid:"+(*it).uid(); 125 //QString uid = "uid:"+(*it).uid();
122#endif 126#endif
123 if ( n.left(6) == "mailto" ) { 127 if ( n.left(6) == "mailto" ) {
124 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 128 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
125#ifndef DESKTOP_VERSION 129#ifndef DESKTOP_VERSION
126 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 130 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
127 e << n.mid(7); 131 e << n.mid(7);
128#endif 132#endif
129 133
130 } 134 }
131 135
132 136
133#ifndef KORG_NODCOP 137#ifndef KORG_NODCOP
134 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 138 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
135 QString tmpStr; 139 QString tmpStr;
136 if (n.startsWith("mailto:")) { 140 if (n.startsWith("mailto:")) {
137 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 141 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
138 //emit showIncidence(n); 142 //emit showIncidence(n);
139 return; 143 return;
140 } else if (n.startsWith("uid:")) { 144 } else if (n.startsWith("uid:")) {
141 DCOPClient *client = KApplication::kApplication()->dcopClient(); 145 DCOPClient *client = KApplication::kApplication()->dcopClient();
142 const QByteArray noParamData; 146 const QByteArray noParamData;
143 const QByteArray paramData; 147 const QByteArray paramData;
144 QByteArray replyData; 148 QByteArray replyData;
145 QCString replyTypeStr; 149 QCString replyTypeStr;
146#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 150#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
147 bool foundAbbrowser = PING_ABBROWSER; 151 bool foundAbbrowser = PING_ABBROWSER;
148 152
149 if (foundAbbrowser) { 153 if (foundAbbrowser) {
150 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 154 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
151 //client->send("kaddressbook","KAddressBookIface", 155 //client->send("kaddressbook","KAddressBookIface",
152 QDataStream arg(paramData, IO_WriteOnly); 156 QDataStream arg(paramData, IO_WriteOnly);
153 arg << n.mid(6); 157 arg << n.mid(6);
154 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 158 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
155 return; 159 return;
156 } else { 160 } else {
157 /* 161 /*
158 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 162 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
159 We start it without its main interface 163 We start it without its main interface
160 */ 164 */
161 KIconLoader* iconLoader = new KIconLoader(); 165 KIconLoader* iconLoader = new KIconLoader();
162 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 166 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
163 ActionManager::setStartedKAddressBook(true); 167 ActionManager::setStartedKAddressBook(true);
164 tmpStr = "kaddressbook --editor-only --uid "; 168 tmpStr = "kaddressbook --editor-only --uid ";
165 tmpStr += KProcess::quote(n.mid(6)); 169 tmpStr += KProcess::quote(n.mid(6));
166 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 170 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
167 return; 171 return;
168 } 172 }
169 } else { 173 } else {
170 //QTextBrowser::setSource(n); 174 //QTextBrowser::setSource(n);
171 } 175 }
172#endif 176#endif
173} 177}
174 178
175void KOEventViewer::addTag(const QString & tag,const QString & text) 179void KOEventViewer::addTag(const QString & tag,const QString & text)
176{ 180{
177 int number=text.contains("\n"); 181 int number=text.contains("\n");
178 QString str = "<" + tag + ">"; 182 QString str = "<" + tag + ">";
179 QString tmpText=text; 183 QString tmpText=text;
180 QString tmpStr=str; 184 QString tmpStr=str;
181 if(number !=-1) 185 if(number !=-1)
182 { 186 {
183 if (number > 0) { 187 if (number > 0) {
184 int pos=0; 188 int pos=0;
185 QString tmp; 189 QString tmp;
186 for(int i=0;i<=number;i++) { 190 for(int i=0;i<=number;i++) {
187 pos=tmpText.find("\n"); 191 pos=tmpText.find("\n");
188 tmp=tmpText.left(pos); 192 tmp=tmpText.left(pos);
189 tmpText=tmpText.right(tmpText.length()-pos-1); 193 tmpText=tmpText.right(tmpText.length()-pos-1);
190 tmpStr+=tmp+"<br>"; 194 tmpStr+=tmp+"<br>";
191 } 195 }
192 } 196 }
193 else tmpStr += tmpText; 197 else tmpStr += tmpText;
194 tmpStr+="</" + tag + ">"; 198 tmpStr+="</" + tag + ">";
195 mText.append(tmpStr); 199 mText.append(tmpStr);
196 } 200 }
197 else 201 else
198 { 202 {
199 str += text + "</" + tag + ">"; 203 str += text + "</" + tag + ">";
200 mText.append(str); 204 mText.append(str);
201 } 205 }
202} 206}
203 207
204void KOEventViewer::setColorMode( int m ) 208void KOEventViewer::setColorMode( int m )
205{ 209{
206 mColorMode = m; 210 mColorMode = m;
207} 211}
208void KOEventViewer::appendEvent(Event *event, int mode ) 212void KOEventViewer::appendEvent(Event *event, int mode )
209{ 213{
210 mMailSubject = ""; 214 mMailSubject = "";
211 mCurrentIncidence = event; 215 mCurrentIncidence = event;
212 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 216 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
213 topLevelWidget()->setCaption(i18n("Event Viewer")); 217 topLevelWidget()->setCaption(i18n("Event Viewer"));
214 if ( mode == 0 ) { 218 if ( mode == 0 ) {
215 addTag("h2",event->summary()); 219 addTag("h2",event->summary());
216 } 220 }
217 else { 221 else {
218 if ( mColorMode == 1 ) { 222 if ( mColorMode == 1 ) {
219 mText +="<font color=\"#00A000\">"; 223 mText +="<font color=\"#00A000\">";
220 } 224 }
221 if ( mColorMode == 2 ) { 225 if ( mColorMode == 2 ) {
222 mText +="<font color=\"#C00000\">"; 226 mText +="<font color=\"#C00000\">";
223 } 227 }
224 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 228 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
225 if ( mode == 1 ) { 229 if ( mode == 1 ) {
226 addTag("h2",i18n( "Local: " ) +event->summary()); 230 addTag("h2",i18n( "Local: " ) +event->summary());
227 } else { 231 } else {
228 addTag("h2",i18n( "Remote: " ) +event->summary()); 232 addTag("h2",i18n( "Remote: " ) +event->summary());
229 } 233 }
230 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 234 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
231 if ( mColorMode ) 235 if ( mColorMode )
232 mText += "</font>"; 236 mText += "</font>";
233 } 237 }
234 mMailSubject += i18n( "Meeting " )+ event->summary(); 238 mMailSubject += i18n( "Meeting " )+ event->summary();
235 if (event->cancelled ()) { 239 if (event->cancelled ()) {
236 mText +="<font color=\"#B00000\">"; 240 mText +="<font color=\"#B00000\">";
237 addTag("i",i18n("This event has been cancelled!")); 241 addTag("i",i18n("This event has been cancelled!"));
238 mText.append("<br>"); 242 mText.append("<br>");
239 mText += "</font>"; 243 mText += "</font>";
240 mMailSubject += i18n("(cancelled)"); 244 mMailSubject += i18n("(cancelled)");
241 } 245 }
242 if (!event->location().isEmpty()) { 246 if (!event->location().isEmpty()) {
243 addTag("b",i18n("Location: ")); 247 addTag("b",i18n("Location: "));
244 mText.append(event->location()+"<br>"); 248 mText.append(event->location()+"<br>");
245 mMailSubject += i18n(" at ") + event->location(); 249 mMailSubject += i18n(" at ") + event->location();
246 } 250 }
247 if (event->doesFloat()) { 251 if (event->doesFloat()) {
248 if (event->isMultiDay()) { 252 if (event->isMultiDay()) {
249 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 253 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
250 .arg(event->dtStartDateStr(shortDate)) 254 .arg(event->dtStartDateStr(shortDate))
251 .arg(event->dtEndDateStr(shortDate))); 255 .arg(event->dtEndDateStr(shortDate)));
252 } else { 256 } else {
253 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 257 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
254 } 258 }
255 } else { 259 } else {
256 if (event->isMultiDay()) { 260 if (event->isMultiDay()) {
257 mText.append(i18n("<p><b>From:</b> %1</p> ") 261 mText.append(i18n("<p><b>From:</b> %1</p> ")
258 .arg(event->dtStartStr( shortDate))); 262 .arg(event->dtStartStr( shortDate)));
259 mText.append(i18n("<p><b>To:</b> %1</p>") 263 mText.append(i18n("<p><b>To:</b> %1</p>")
260 .arg(event->dtEndStr(shortDate))); 264 .arg(event->dtEndStr(shortDate)));
261 } else { 265 } else {
262 mText.append(i18n("<p><b>On:</b> %1</p> ") 266 mText.append(i18n("<p><b>On:</b> %1</p> ")
263 .arg(event->dtStartDateStr( shortDate ))); 267 .arg(event->dtStartDateStr( shortDate )));
264 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 268 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
265 .arg(event->dtStartTimeStr()) 269 .arg(event->dtStartTimeStr())
266 .arg(event->dtEndTimeStr())); 270 .arg(event->dtEndTimeStr()));
267 } 271 }
268 } 272 }
269 273
270 if (event->recurrence()->doesRecur()) { 274 if (event->recurrence()->doesRecur()) {
271 275
272 QString recurText = event->recurrence()->recurrenceText(); 276 QString recurText = event->recurrence()->recurrenceText();
273 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 277 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
274 bool last; 278 bool last;
275 QDate start = QDate::currentDate(); 279 QDate start = QDate::currentDate();
276 QDate next; 280 QDate next;
277 next = event->recurrence()->getPreviousDate( start , &last ); 281 next = event->recurrence()->getPreviousDate( start , &last );
278 if ( !last ) { 282 if ( !last ) {
279 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 283 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
280 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 284 addTag("p",i18n("<b>Next recurrence is on:</b>") );
281 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 285 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
282 QDateTime nextdt = QDateTime( next, event->dtStart().time()); 286 QDateTime nextdt = QDateTime( next, event->dtStart().time());
283 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); 287 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
284 288
285 } else { 289 } else {
286 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 290 addTag("p",i18n("<b>Last recurrence was on:</b>") );
287 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 291 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
288 } 292 }
289 } else { 293 } else {
290 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 294 mMailSubject += i18n(" - " )+event->dtStartStr( true );
291 295
292 } 296 }
293 297
294 298
295 if (event->isAlarmEnabled()) { 299 if (event->isAlarmEnabled()) {
296 Alarm *alarm =event->alarms().first() ; 300 Alarm *alarm =event->alarms().first() ;
297 QDateTime t = alarm->time(); 301 QDateTime t = alarm->time();
298 int min = t.secsTo( event->dtStart() )/60; 302 int min = t.secsTo( event->dtStart() )/60;
299 QString s =i18n("( %1 min before )").arg( min ); 303 QString s =i18n("( %1 min before )").arg( min );
300 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 304 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
301 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 305 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
302 //addTag("p",s); 306 //addTag("p",s);
303 } 307 }
304 308
305 addTag("b",i18n("Access: ")); 309 addTag("b",i18n("Access: "));
306 mText.append(event->secrecyStr()+"<br>"); 310 mText.append(event->secrecyStr()+"<br>");
307 if (!event->description().isEmpty()) { 311 if (!event->description().isEmpty()) {
308 addTag("p",i18n("<b>Details: </b>")); 312 addTag("p",i18n("<b>Details: </b>"));
309 addTag("p",event->description()); 313 addTag("p",event->description());
310 } 314 }
311 315
312 formatCategories(event); 316 formatCategories(event);
313 317
314 formatReadOnly(event); 318 formatReadOnly(event);
315 formatAttendees(event); 319 formatAttendees(event);
316 320
317 setText(mText); 321 setText(mText);
318 //QWhatsThis::add(this,mText); 322 //QWhatsThis::add(this,mText);
319 323
320} 324}
321 325
322void KOEventViewer::appendTodo(Todo *event, int mode ) 326void KOEventViewer::appendTodo(Todo *event, int mode )
323{ 327{
324 mMailSubject = ""; 328 mMailSubject = "";
325 mCurrentIncidence = event; 329 mCurrentIncidence = event;
326 topLevelWidget()->setCaption(i18n("Todo Viewer")); 330 topLevelWidget()->setCaption(i18n("Todo Viewer"));
327 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 331 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
328 if (mode == 0 ) 332 if (mode == 0 )
329 addTag("h2",event->summary()); 333 addTag("h2",event->summary());
330 else { 334 else {
331 if ( mColorMode == 1 ) { 335 if ( mColorMode == 1 ) {
332 mText +="<font color=\"#00A000\">"; 336 mText +="<font color=\"#00A000\">";
333 } 337 }
334 if ( mColorMode == 2 ) { 338 if ( mColorMode == 2 ) {
335 mText +="<font color=\"#B00000\">"; 339 mText +="<font color=\"#B00000\">";
336 } 340 }
337 if ( mode == 1 ) { 341 if ( mode == 1 ) {
338 addTag("h2",i18n( "Local: " ) +event->summary()); 342 addTag("h2",i18n( "Local: " ) +event->summary());
339 } else { 343 } else {
340 addTag("h2",i18n( "Remote: " ) +event->summary()); 344 addTag("h2",i18n( "Remote: " ) +event->summary());
341 } 345 }
342 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 346 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
343 if ( mColorMode ) 347 if ( mColorMode )
344 mText += "</font>"; 348 mText += "</font>";
345 } 349 }
346 mMailSubject += i18n( "Todo " )+ event->summary(); 350 mMailSubject += i18n( "Todo " )+ event->summary();
347 if (event->cancelled ()) { 351 if (event->cancelled ()) {
348 mText +="<font color=\"#B00000\">"; 352 mText +="<font color=\"#B00000\">";
349 addTag("i",i18n("This todo has been cancelled!")); 353 addTag("i",i18n("This todo has been cancelled!"));
350 mText.append("<br>"); 354 mText.append("<br>");
351 mText += "</font>"; 355 mText += "</font>";
352 mMailSubject += i18n("(cancelled)"); 356 mMailSubject += i18n("(cancelled)");
353 } 357 }
354 358
355 if (!event->location().isEmpty()) { 359 if (!event->location().isEmpty()) {
356 addTag("b",i18n("Location: ")); 360 addTag("b",i18n("Location: "));
357 mText.append(event->location()+"<br>"); 361 mText.append(event->location()+"<br>");
358 mMailSubject += i18n(" at ") + event->location(); 362 mMailSubject += i18n(" at ") + event->location();
359 } 363 }
360 if (event->hasDueDate()) { 364 if (event->hasDueDate()) {
361 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 365 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
362 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 366 mMailSubject += i18n(" - " )+event->dtDueStr( true );
363 } 367 }
364 addTag("b",i18n("Access: ")); 368 addTag("b",i18n("Access: "));
365 mText.append(event->secrecyStr()+"<br>"); 369 mText.append(event->secrecyStr()+"<br>");
366 if (!event->description().isEmpty()) { 370 if (!event->description().isEmpty()) {
367 addTag("p",i18n("<b>Details: </b>")); 371 addTag("p",i18n("<b>Details: </b>"));
368 addTag("p",event->description()); 372 addTag("p",event->description());
369 } 373 }
370 374
371 formatCategories(event); 375 formatCategories(event);
372 376
373 mText.append(i18n("<p><b>Priority:</b> %2</p>") 377 mText.append(i18n("<p><b>Priority:</b> %2</p>")
374 .arg(QString::number(event->priority()))); 378 .arg(QString::number(event->priority())));
375 379
376 mText.append(i18n("<p><i>%1 % completed</i></p>") 380 mText.append(i18n("<p><i>%1 % completed</i></p>")
377 .arg(event->percentComplete())); 381 .arg(event->percentComplete()));
378 382
379 formatReadOnly(event); 383 formatReadOnly(event);
380 formatAttendees(event); 384 formatAttendees(event);
381 385
382 setText(mText); 386 setText(mText);
383} 387}
384 388
385void KOEventViewer::formatCategories(Incidence *event) 389void KOEventViewer::formatCategories(Incidence *event)
386{ 390{
387 if (!event->categoriesStr().isEmpty()) { 391 if (!event->categoriesStr().isEmpty()) {
388 if (event->categories().count() == 1) { 392 if (event->categories().count() == 1) {
389 addTag("h3",i18n("Category")); 393 addTag("h3",i18n("Category"));
390 } else { 394 } else {
391 addTag("h3",i18n("Categories")); 395 addTag("h3",i18n("Categories"));
392 } 396 }
393 addTag("p",event->categoriesStr()); 397 addTag("p",event->categoriesStr());
394 } 398 }
395} 399}
396void KOEventViewer::formatAttendees(Incidence *event) 400void KOEventViewer::formatAttendees(Incidence *event)
397{ 401{
398 QPtrList<Attendee> attendees = event->attendees(); 402 QPtrList<Attendee> attendees = event->attendees();
399 if (attendees.count()) { 403 if (attendees.count()) {
400 404
401 405
402 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 406 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
403 addTag("h3",i18n("Organizer")); 407 addTag("h3",i18n("Organizer"));
404 mText.append("<ul><li>"); 408 mText.append("<ul><li>");
405#ifndef KORG_NOKABC 409#ifndef KORG_NOKABC
406 410
407#ifdef DESKTOP_VERSION 411#ifdef DESKTOP_VERSION
408 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 412 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
409 KABC::Addressee::List addressList; 413 KABC::Addressee::List addressList;
410 addressList = add_book->findByEmail(event->organizer()); 414 addressList = add_book->findByEmail(event->organizer());
411 KABC::Addressee o = addressList.first(); 415 KABC::Addressee o = addressList.first();
412 if (!o.isEmpty() && addressList.size()<2) { 416 if (!o.isEmpty() && addressList.size()<2) {
413 mText += "<a href=\"uid:" + o.uid() + "\">"; 417 mText += "<a href=\"uid:" + o.uid() + "\">";
414 mText += o.formattedName(); 418 mText += o.formattedName();
415 mText += "</a>\n"; 419 mText += "</a>\n";
416 } else { 420 } else {
417 mText.append(event->organizer()); 421 mText.append(event->organizer());
418 } 422 }
419#else //DESKTOP_VERSION 423#else //DESKTOP_VERSION
420 mText.append(event->organizer()); 424 mText += "<a href=\"uid:organizer\">";
425 mText += event->organizer();
426 mText += "</a>\n";
421#endif //DESKTOP_VERSION 427#endif //DESKTOP_VERSION
422 428
423 429
424#else 430#else
425 mText.append(event->organizer()); 431 mText.append(event->organizer());
426#endif 432#endif
427 433
428 if (iconPath) { 434 if (iconPath) {
429 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 435 mText += " <a href=\"mailto:" + event->organizer() + "\">";
430 mText += "<IMG src=\"" + iconPath + "\">"; 436 mText += "<IMG src=\"" + iconPath + "\">";
431 mText += "</a>\n"; 437 mText += "</a>\n";
432 } 438 }
433 mText.append("</li></ul>"); 439 mText.append("</li></ul>");
434 440
435 addTag("h3",i18n("Attendees")); 441 addTag("h3",i18n("Attendees"));
436 Attendee *a; 442 Attendee *a;
437 mText.append("<ul>"); 443 mText.append("<ul>");
438 for(a=attendees.first();a;a=attendees.next()) { 444 for(a=attendees.first();a;a=attendees.next()) {
439#ifndef KORG_NOKABC 445#ifndef KORG_NOKABC
440#ifdef DESKTOP_VERSION 446#ifdef DESKTOP_VERSION
441 if (a->name().isEmpty()) { 447 if (a->name().isEmpty()) {
442 addressList = add_book->findByEmail(a->email()); 448 addressList = add_book->findByEmail(a->email());
443 KABC::Addressee o = addressList.first(); 449 KABC::Addressee o = addressList.first();
444 if (!o.isEmpty() && addressList.size()<2) { 450 if (!o.isEmpty() && addressList.size()<2) {
445 mText += "<a href=\"uid:" + o.uid() + "\">"; 451 mText += "<a href=\"uid:" + o.uid() + "\">";
446 mText += o.formattedName(); 452 mText += o.formattedName();
447 mText += "</a>\n"; 453 mText += "</a>\n";
448 } else { 454 } else {
449 mText += "<li>"; 455 mText += "<li>";
450 mText.append(a->email()); 456 mText.append(a->email());
451 mText += "\n"; 457 mText += "\n";
452 } 458 }
453 } else { 459 } else {
454 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 460 mText += "<li><a href=\"uid:" + a->uid() + "\">";
455 if (!a->name().isEmpty()) mText += a->name(); 461 if (!a->name().isEmpty()) mText += a->name();
456 else mText += a->email(); 462 else mText += a->email();
457 mText += "</a>\n"; 463 mText += "</a>\n";
458 } 464 }
459#else //DESKTOP_VERSION 465#else //DESKTOP_VERSION
460 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 466 mText += "<li><a href=\"uid:" + a->uid() + "\">";
461 if (!a->name().isEmpty()) mText += a->name(); 467 if (!a->name().isEmpty()) mText += a->name();
462 else mText += a->email(); 468 else mText += a->email();
463 mText += "</a>\n"; 469 mText += "</a>\n";
464#endif //DESKTOP_VERSION 470#endif //DESKTOP_VERSION
465#else 471#else
466 //qDebug("nokabc "); 472 //qDebug("nokabc ");
467 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 473 mText += "<li><a href=\"uid:" + a->uid() + "\">";
468 if (!a->name().isEmpty()) mText += a->name(); 474 if (!a->name().isEmpty()) mText += a->name();
469 else mText += a->email(); 475 else mText += a->email();
470 mText += "</a>\n"; 476 mText += "</a>\n";
471#endif 477#endif
472 478
473 479
474 if (!a->email().isEmpty()) { 480 if (!a->email().isEmpty()) {
475 if (iconPath) { 481 if (iconPath) {
476 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 482 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
477 mText += "<IMG src=\"" + iconPath + "\">"; 483 mText += "<IMG src=\"" + iconPath + "\">";
478 mText += "</a>\n"; 484 mText += "</a>\n";
479 } 485 }
480 } 486 }
481 if (a->status() != Attendee::NeedsAction ) 487 if (a->status() != Attendee::NeedsAction )
482 mText +="[" + a->statusStr() + "] "; 488 mText +="[" + a->statusStr() + "] ";
483 if (a->role() == Attendee::Chair ) 489 if (a->role() == Attendee::Chair )
484 mText +="(" + a->roleStr().left(1) + ".)"; 490 mText +="(" + a->roleStr().left(1) + ".)";
485 } 491 }
486 mText.append("</li></ul>"); 492 mText.append("</li></ul>");
487 } 493 }
488 494
489} 495}
490void KOEventViewer::appendJournal(Journal *jour, int mode ) 496void KOEventViewer::appendJournal(Journal *jour, int mode )
491{ 497{
492 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 498 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
493 if (mode == 0 ) 499 if (mode == 0 )
494 addTag("h2",i18n("Journal from: ")); 500 addTag("h2",i18n("Journal from: "));
495 else { 501 else {
496 if ( mode == 1 ) { 502 if ( mode == 1 ) {
497 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 503 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
498 } else { 504 } else {
499 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 505 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
500 } 506 }
501 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 507 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
502 } 508 }
503 topLevelWidget()->setCaption("Journal Viewer"); 509 topLevelWidget()->setCaption("Journal Viewer");
504 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 510 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
505 if (!jour->description().isEmpty()) { 511 if (!jour->description().isEmpty()) {
506 addTag("p",jour->description()); 512 addTag("p",jour->description());
507 } 513 }
508 setText(mText); 514 setText(mText);
509} 515}
510 516
511void KOEventViewer::formatReadOnly(Incidence *event) 517void KOEventViewer::formatReadOnly(Incidence *event)
512{ 518{
513 if (event->isReadOnly()) { 519 if (event->isReadOnly()) {
514 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 520 addTag("p","<em>(" + i18n("read-only") + ")</em>");
515 } 521 }
516} 522}
517void KOEventViewer::setSyncMode( bool b ) 523void KOEventViewer::setSyncMode( bool b )
518{ 524{
519 mSyncMode = b; 525 mSyncMode = b;
520} 526}
521 527
522 528
523void KOEventViewer::setTodo(Todo *event, bool clearV ) 529void KOEventViewer::setTodo(Todo *event, bool clearV )
524{ 530{
525 if ( clearV ) 531 if ( clearV )
526 clearEvents(); 532 clearEvents();
527 if ( mSyncMode ) { 533 if ( mSyncMode ) {
528 if ( clearV ) 534 if ( clearV )
529 appendTodo(event,1 ); 535 appendTodo(event,1 );
530 else 536 else
531 appendTodo(event,2); 537 appendTodo(event,2);
532 } else 538 } else
533 appendTodo(event); 539 appendTodo(event);
534} 540}
535void KOEventViewer::setJournal(Journal *event, bool clearV ) 541void KOEventViewer::setJournal(Journal *event, bool clearV )
536{ 542{
537 if ( clearV ) 543 if ( clearV )
538 clearEvents(); 544 clearEvents();
539 if ( mSyncMode ) { 545 if ( mSyncMode ) {
540 if ( clearV ) 546 if ( clearV )
541 appendJournal(event, 1); 547 appendJournal(event, 1);
542 else 548 else
543 appendJournal(event, 2); 549 appendJournal(event, 2);
544 } else 550 } else
545 appendJournal(event); 551 appendJournal(event);
546} 552}
547 553
548void KOEventViewer::setEvent(Event *event) 554void KOEventViewer::setEvent(Event *event)
549{ 555{
550 clearEvents(); 556 clearEvents();
551 if ( mSyncMode ) 557 if ( mSyncMode )
552 appendEvent(event, 1); 558 appendEvent(event, 1);
553 else 559 else
554 appendEvent(event); 560 appendEvent(event);
555} 561}
556 562
557void KOEventViewer::addEvent(Event *event) 563void KOEventViewer::addEvent(Event *event)
558{ 564{
559 if ( mSyncMode ) 565 if ( mSyncMode )
560 appendEvent(event, 2); 566 appendEvent(event, 2);
561 else 567 else
562 appendEvent(event); 568 appendEvent(event);
563} 569}
564 570
565void KOEventViewer::clearEvents(bool now) 571void KOEventViewer::clearEvents(bool now)
566{ 572{
567 mText = ""; 573 mText = "";
568 if (now) setText(mText); 574 if (now) setText(mText);
569} 575}
570 576
571void KOEventViewer::addText(QString text) 577void KOEventViewer::addText(QString text)
572{ 578{
573 mText.append(text); 579 mText.append(text);
574 setText(mText); 580 setText(mText);
575} 581}