summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-10 14:36:13 (UTC)
committer zautrix <zautrix>2005-03-10 14:36:13 (UTC)
commit34f5a1b758adb98c466ae8e45c9d980d62dfc544 (patch) (unidiff)
tree1ba10eac4df592da4b284bae029a864e40314d18
parentb96161e4dd7fc19eea87257c2455b85420dad35a (diff)
downloadkdepimpi-34f5a1b758adb98c466ae8e45c9d980d62dfc544.zip
kdepimpi-34f5a1b758adb98c466ae8e45c9d980d62dfc544.tar.gz
kdepimpi-34f5a1b758adb98c466ae8e45c9d980d62dfc544.tar.bz2
htmal tag fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp42
-rw-r--r--korganizer/koeventviewer.h1
-rw-r--r--libkcal/kincidenceformatter.cpp35
-rw-r--r--libkcal/kincidenceformatter.h1
4 files changed, 55 insertions, 24 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 44da058..135ca73 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,707 +1,721 @@
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 <kabc/stdaddressbook.h> 38#include <kabc/stdaddressbook.h>
39 39
40#ifndef KORG_NODCOP 40#ifndef KORG_NODCOP
41#include <dcopclient.h> 41#include <dcopclient.h>
42#include "korganizer.h" 42#include "korganizer.h"
43#include "koprefs.h" 43#include "koprefs.h"
44#include "actionmanager.h" 44#include "actionmanager.h"
45#endif 45#endif
46 46
47#include "koeventviewer.h" 47#include "koeventviewer.h"
48//#ifndef KORG_NOKABC 48//#ifndef KORG_NOKABC
49//#include <kabc/stdaddressbook.h> 49//#include <kabc/stdaddressbook.h>
50//#define size count 50//#define size count
51//#endif 51//#endif
52 52
53#ifdef DESKTOP_VERSION 53#ifdef DESKTOP_VERSION
54#include <kabc/addresseedialog.h> 54#include <kabc/addresseedialog.h>
55#include <kabc/addresseeview.h> 55#include <kabc/addresseeview.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 KABC::AddresseeView av ( &dia ); 90 KABC::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 dia.exec(); 98 dia.exec();
99 break; 99 break;
100 } 100 }
101 } 101 }
102 return; 102 return;
103 } 103 }
104#else 104#else
105 { 105 {
106 if ( "uid:organizer" == n ) { 106 if ( "uid:organizer" == n ) {
107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 107 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
108 return; 108 return;
109 } 109 }
110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 110 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
111 if (attendees.count()) { 111 if (attendees.count()) {
112 Attendee *a; 112 Attendee *a;
113 for(a=attendees.first();a;a=attendees.next()) { 113 for(a=attendees.first();a;a=attendees.next()) {
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",deTag(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: " ) +deTag(event->summary()));
259 } else { 259 } else {
260 addTag("h2",i18n( "Remote: " ) +event->summary()); 260 addTag("h2",i18n( "Remote: " ) +deTag(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(deTag(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 ok; 306 bool ok;
307 QDate start = QDate::currentDate(); 307 QDate start = QDate::currentDate();
308 QDateTime next; 308 QDateTime next;
309 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 309 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
310 if ( ok ) { 310 if ( ok ) {
311 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 311 addTag("p",i18n("<b>Next recurrence is on:</b>") );
312 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 312 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
313 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); 313 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true );
314 314
315 } else { 315 } else {
316 bool last; 316 bool last;
317 QDate nextd; 317 QDate nextd;
318 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 318 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
319 if ( last ) { 319 if ( last ) {
320 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 320 addTag("p",i18n("<b>Last recurrence was on:</b>") );
321 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 321 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
322 } 322 }
323 } 323 }
324 } else { 324 } else {
325 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 325 mMailSubject += i18n(" - " )+event->dtStartStr( true );
326 326
327 } 327 }
328 328
329 329
330 if (event->isAlarmEnabled()) { 330 if (event->isAlarmEnabled()) {
331 Alarm *alarm =event->alarms().first() ; 331 Alarm *alarm =event->alarms().first() ;
332 QDateTime t = alarm->time(); 332 QDateTime t = alarm->time();
333 int min = t.secsTo( event->dtStart() )/60; 333 int min = t.secsTo( event->dtStart() )/60;
334 QString s =i18n("( %1 min before )").arg( min ); 334 QString s =i18n("( %1 min before )").arg( min );
335 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 335 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
336 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 336 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
337 //addTag("p",s); 337 //addTag("p",s);
338 } 338 }
339 339
340 addTag("b",i18n("Access: ")); 340 addTag("b",i18n("Access: "));
341 mText.append(event->secrecyStr()+"<br>"); 341 mText.append(event->secrecyStr()+"<br>");
342 342
343 343
344 if ( KOPrefs::instance()->mEVshowDetails ) { 344 if ( KOPrefs::instance()->mEVshowDetails ) {
345 if (!event->description().isEmpty()) { 345 if (!event->description().isEmpty()) {
346 addTag("p",i18n("<b>Details: </b>")); 346 addTag("p",i18n("<b>Details: </b>"));
347 addTag("p",event->description()); 347 addTag("p",deTag(event->description()));
348 } 348 }
349 } 349 }
350 formatCategories(event); 350 formatCategories(event);
351 351
352 formatReadOnly(event); 352 formatReadOnly(event);
353 formatAttendees(event); 353 formatAttendees(event);
354 354
355 if ( KOPrefs::instance()->mEVshowCreated ) { 355 if ( KOPrefs::instance()->mEVshowCreated ) {
356 addTag("p",i18n("<b>Created: ") +" </b>"); 356 addTag("p",i18n("<b>Created: ") +" </b>");
357 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 357 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
358 358
359 } 359 }
360 if ( KOPrefs::instance()->mEVshowChanged ) { 360 if ( KOPrefs::instance()->mEVshowChanged ) {
361 addTag("p",i18n("<b>Last modified: ") +" </b>"); 361 addTag("p",i18n("<b>Last modified: ") +" </b>");
362 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 362 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
363 363
364 } 364 }
365 setText(mText); 365 setText(mText);
366 //QWhatsThis::add(this,mText); 366 //QWhatsThis::add(this,mText);
367 367
368} 368}
369 369
370void KOEventViewer::appendTodo(Todo *event, int mode ) 370void KOEventViewer::appendTodo(Todo *event, int mode )
371{ 371{
372 mMailSubject = ""; 372 mMailSubject = "";
373 mCurrentIncidence = event; 373 mCurrentIncidence = event;
374 topLevelWidget()->setCaption(i18n("Todo Viewer")); 374 topLevelWidget()->setCaption(i18n("Todo Viewer"));
375 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 375 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
376 if (mode == 0 ) 376 if (mode == 0 )
377 addTag("h2",event->summary()); 377 addTag("h2",deTag(event->summary()));
378 else { 378 else {
379 if ( mColorMode == 1 ) { 379 if ( mColorMode == 1 ) {
380 mText +="<font color=\"#00A000\">"; 380 mText +="<font color=\"#00A000\">";
381 } 381 }
382 if ( mColorMode == 2 ) { 382 if ( mColorMode == 2 ) {
383 mText +="<font color=\"#B00000\">"; 383 mText +="<font color=\"#B00000\">";
384 } 384 }
385 if ( mode == 1 ) { 385 if ( mode == 1 ) {
386 addTag("h2",i18n( "Local: " ) +event->summary()); 386 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
387 } else { 387 } else {
388 addTag("h2",i18n( "Remote: " ) +event->summary()); 388 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
389 } 389 }
390 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 390 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
391 if ( mColorMode ) 391 if ( mColorMode )
392 mText += "</font>"; 392 mText += "</font>";
393 } 393 }
394 mMailSubject += i18n( "Todo " )+ event->summary(); 394 mMailSubject += i18n( "Todo " )+ event->summary();
395 395
396 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 396 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
397 mText +="<font color=\"#B00000\">"; 397 mText +="<font color=\"#B00000\">";
398 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); 398 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) );
399 mText += "</font>"; 399 mText += "</font>";
400 } else { 400 } else {
401 mText.append(i18n("<p><i>%1 % completed</i></p>") 401 mText.append(i18n("<p><i>%1 % completed</i></p>")
402 .arg(event->percentComplete())); 402 .arg(event->percentComplete()));
403 } 403 }
404 404
405 if (event->cancelled ()) { 405 if (event->cancelled ()) {
406 mText +="<font color=\"#B00000\">"; 406 mText +="<font color=\"#B00000\">";
407 addTag("i",i18n("This todo has been cancelled!")); 407 addTag("i",i18n("This todo has been cancelled!"));
408 mText.append("<br>"); 408 mText.append("<br>");
409 mText += "</font>"; 409 mText += "</font>";
410 mMailSubject += i18n("(cancelled)"); 410 mMailSubject += i18n("(cancelled)");
411 } 411 }
412 412
413 if (!event->location().isEmpty()) { 413 if (!event->location().isEmpty()) {
414 addTag("b",i18n("Location: ")); 414 addTag("b",i18n("Location: "));
415 mText.append(event->location()+"<br>"); 415 mText.append(deTag(event->location())+"<br>");
416 mMailSubject += i18n(" at ") + event->location(); 416 mMailSubject += i18n(" at ") + event->location();
417 } 417 }
418 418
419 if (event->recurrence()->doesRecur()) { 419 if (event->recurrence()->doesRecur()) {
420 420
421 QString recurText = event->recurrence()->recurrenceText(); 421 QString recurText = event->recurrence()->recurrenceText();
422 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); 422 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>");
423 423
424 } 424 }
425 if (event->hasStartDate()) { 425 if (event->hasStartDate()) {
426 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 426 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
427 } 427 }
428 if (event->hasDueDate()) { 428 if (event->hasDueDate()) {
429 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 429 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
430 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 430 mMailSubject += i18n(" - " )+event->dtDueStr( true );
431 } 431 }
432 addTag("b",i18n("Access: ")); 432 addTag("b",i18n("Access: "));
433 mText.append(event->secrecyStr()+"<br>"); 433 mText.append(event->secrecyStr()+"<br>");
434 if ( KOPrefs::instance()->mEVshowDetails ) { 434 if ( KOPrefs::instance()->mEVshowDetails ) {
435 if (!event->description().isEmpty()) { 435 if (!event->description().isEmpty()) {
436 addTag("p",i18n("<b>Details: </b>")); 436 addTag("p",i18n("<b>Details: </b>"));
437 addTag("p",event->description()); 437 addTag("p",deTag(event->description()));
438 } 438 }
439 } 439 }
440 440
441 formatCategories(event); 441 formatCategories(event);
442 442
443 mText.append(i18n("<p><b>Priority:</b> %2</p>") 443 mText.append(i18n("<p><b>Priority:</b> %2</p>")
444 .arg(QString::number(event->priority()))); 444 .arg(QString::number(event->priority())));
445 445
446 formatReadOnly(event); 446 formatReadOnly(event);
447 formatAttendees(event); 447 formatAttendees(event);
448 if ( event->relatedTo() ) { 448 if ( event->relatedTo() ) {
449 addTag("b",i18n("Parent todo:<br>")); 449 addTag("b",i18n("Parent todo:<br>"));
450 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 450 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
451 } 451 }
452 QPtrList<Incidence> Relations = event->relations(); 452 QPtrList<Incidence> Relations = event->relations();
453 Incidence *to; 453 Incidence *to;
454 if ( Relations.first() ) 454 if ( Relations.first() )
455 addTag("b",i18n("Sub todos:<br>")); 455 addTag("b",i18n("Sub todos:<br>"));
456 for (to=Relations.first();to;to=Relations.next()) { 456 for (to=Relations.first();to;to=Relations.next()) {
457 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 457 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
458 458
459 } 459 }
460 if ( KOPrefs::instance()->mEVshowCreated ) { 460 if ( KOPrefs::instance()->mEVshowCreated ) {
461 addTag("p",i18n("<b>Created: ") +" </b>"); 461 addTag("p",i18n("<b>Created: ") +" </b>");
462 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 462 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
463 463
464 } 464 }
465 if ( KOPrefs::instance()->mEVshowChanged ) { 465 if ( KOPrefs::instance()->mEVshowChanged ) {
466 addTag("p",i18n("<b>Last modified: ") +" </b>"); 466 addTag("p",i18n("<b>Last modified: ") +" </b>");
467 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 467 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
468 468
469 } 469 }
470 setText(mText); 470 setText(mText);
471} 471}
472 472
473void KOEventViewer::formatCategories(Incidence *event) 473void KOEventViewer::formatCategories(Incidence *event)
474{ 474{
475 if (!event->categoriesStr().isEmpty()) { 475 if (!event->categoriesStr().isEmpty()) {
476 if (event->categories().count() == 1) { 476 if (event->categories().count() == 1) {
477 addTag("h3",i18n("Category")); 477 addTag("h3",i18n("Category"));
478 } else { 478 } else {
479 addTag("h3",i18n("Categories")); 479 addTag("h3",i18n("Categories"));
480 } 480 }
481 addTag("p",event->categoriesStr()); 481 addTag("p",event->categoriesStr());
482 } 482 }
483} 483}
484void KOEventViewer::formatAttendees(Incidence *event) 484void KOEventViewer::formatAttendees(Incidence *event)
485{ 485{
486 QPtrList<Attendee> attendees = event->attendees(); 486 QPtrList<Attendee> attendees = event->attendees();
487 if (attendees.count()) { 487 if (attendees.count()) {
488 488
489 489
490 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 490 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
491 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 491 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
492 addTag("h3",i18n("Organizer")); 492 addTag("h3",i18n("Organizer"));
493 mText.append("<ul><li>"); 493 mText.append("<ul><li>");
494#ifndef KORG_NOKABC 494#ifndef KORG_NOKABC
495 495
496#ifdef DESKTOP_VERSION 496#ifdef DESKTOP_VERSION
497 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 497 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
498 KABC::Addressee::List addressList; 498 KABC::Addressee::List addressList;
499 addressList = add_book->findByEmail(event->organizer()); 499 addressList = add_book->findByEmail(event->organizer());
500 KABC::Addressee o = addressList.first(); 500 KABC::Addressee o = addressList.first();
501 if (!o.isEmpty() && addressList.size()<2) { 501 if (!o.isEmpty() && addressList.size()<2) {
502 mText += "<a href=\"uid:" + o.uid() + "\">"; 502 mText += "<a href=\"uid:" + o.uid() + "\">";
503 mText += o.formattedName(); 503 mText += o.formattedName();
504 mText += "</a>\n"; 504 mText += "</a>\n";
505 } else { 505 } else {
506 mText.append(event->organizer()); 506 mText.append(event->organizer());
507 } 507 }
508#else //DESKTOP_VERSION 508#else //DESKTOP_VERSION
509 mText += "<a href=\"uid:organizer\">"; 509 mText += "<a href=\"uid:organizer\">";
510 mText += event->organizer(); 510 mText += event->organizer();
511 mText += "</a>\n"; 511 mText += "</a>\n";
512#endif //DESKTOP_VERSION 512#endif //DESKTOP_VERSION
513 513
514 514
515#else 515#else
516 mText.append(event->organizer()); 516 mText.append(event->organizer());
517#endif 517#endif
518 518
519 if (iconPath) { 519 if (iconPath) {
520 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 520 mText += " <a href=\"mailto:" + event->organizer() + "\">";
521 mText += "<IMG src=\"" + iconPath + "\">"; 521 mText += "<IMG src=\"" + iconPath + "\">";
522 mText += "</a>\n"; 522 mText += "</a>\n";
523 } 523 }
524 mText.append("</li></ul>"); 524 mText.append("</li></ul>");
525 525
526 addTag("h3",i18n("Attendees")); 526 addTag("h3",i18n("Attendees"));
527 Attendee *a; 527 Attendee *a;
528 mText.append("<ul>"); 528 mText.append("<ul>");
529 int a_count = 0; 529 int a_count = 0;
530 int a_count_nr = 0; 530 int a_count_nr = 0;
531 531
532 for(a=attendees.first();a;a=attendees.next()) { 532 for(a=attendees.first();a;a=attendees.next()) {
533#ifndef KORG_NOKABC 533#ifndef KORG_NOKABC
534#ifdef DESKTOP_VERSION 534#ifdef DESKTOP_VERSION
535 if (a->name().isEmpty()) { 535 if (a->name().isEmpty()) {
536 addressList = add_book->findByEmail(a->email()); 536 addressList = add_book->findByEmail(a->email());
537 KABC::Addressee o = addressList.first(); 537 KABC::Addressee o = addressList.first();
538 if (!o.isEmpty() && addressList.size()<2) { 538 if (!o.isEmpty() && addressList.size()<2) {
539 mText += "<a href=\"uid:" + o.uid() + "\">"; 539 mText += "<a href=\"uid:" + o.uid() + "\">";
540 mText += o.formattedName(); 540 mText += o.formattedName();
541 mText += "</a>\n"; 541 mText += "</a>\n";
542 } else { 542 } else {
543 mText += "<li>"; 543 mText += "<li>";
544 mText.append(a->email()); 544 mText.append(a->email());
545 mText += "\n"; 545 mText += "\n";
546 } 546 }
547 } else { 547 } else {
548 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 548 mText += "<li><a href=\"uid:" + a->uid() + "\">";
549 if (!a->name().isEmpty()) mText += a->name(); 549 if (!a->name().isEmpty()) mText += a->name();
550 else mText += a->email(); 550 else mText += a->email();
551 mText += "</a>\n"; 551 mText += "</a>\n";
552 } 552 }
553#else //DESKTOP_VERSION 553#else //DESKTOP_VERSION
554 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 554 mText += "<li><a href=\"uid:" + a->uid() + "\">";
555 if (!a->name().isEmpty()) mText += a->name(); 555 if (!a->name().isEmpty()) mText += a->name();
556 else mText += a->email(); 556 else mText += a->email();
557 mText += "</a>\n"; 557 mText += "</a>\n";
558#endif //DESKTOP_VERSION 558#endif //DESKTOP_VERSION
559#else 559#else
560 //qDebug("nokabc "); 560 //qDebug("nokabc ");
561 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 561 mText += "<li><a href=\"uid:" + a->uid() + "\">";
562 if (!a->name().isEmpty()) mText += a->name(); 562 if (!a->name().isEmpty()) mText += a->name();
563 else mText += a->email(); 563 else mText += a->email();
564 mText += "</a>\n"; 564 mText += "</a>\n";
565#endif 565#endif
566 566
567 567
568 if (!a->email().isEmpty()) { 568 if (!a->email().isEmpty()) {
569 if (iconPath) { 569 if (iconPath) {
570 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 570 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
571 if ( a->RSVP() ) { 571 if ( a->RSVP() ) {
572 ++a_count_nr; 572 ++a_count_nr;
573 mText += "<IMG src=\"" + iconPath + "\">"; 573 mText += "<IMG src=\"" + iconPath + "\">";
574 } 574 }
575 else { 575 else {
576 ++a_count; 576 ++a_count;
577 mText += "<IMG src=\"" + NOiconPath + "\">"; 577 mText += "<IMG src=\"" + NOiconPath + "\">";
578 } 578 }
579 mText += "</a>\n"; 579 mText += "</a>\n";
580 } 580 }
581 } 581 }
582 if (a->status() != Attendee::NeedsAction ) 582 if (a->status() != Attendee::NeedsAction )
583 mText +="[" + a->statusStr() + "] "; 583 mText +="[" + a->statusStr() + "] ";
584 if (a->role() == Attendee::Chair ) 584 if (a->role() == Attendee::Chair )
585 mText +="(" + a->roleStr().left(1) + ".)"; 585 mText +="(" + a->roleStr().left(1) + ".)";
586 } 586 }
587 mText.append("</li></ul>"); 587 mText.append("</li></ul>");
588 if ( (a_count+a_count_nr) > 1 ) { 588 if ( (a_count+a_count_nr) > 1 ) {
589 mText += "<a href=\"mailto:ALL\">"; 589 mText += "<a href=\"mailto:ALL\">";
590 mText += i18n( "Mail to all" ); 590 mText += i18n( "Mail to all" );
591 mText += "</a> ( "; 591 mText += "</a> ( ";
592 mText += "<IMG src=\"" + iconPath + "\">"; 592 mText += "<IMG src=\"" + iconPath + "\">";
593 mText += i18n( " and " ); 593 mText += i18n( " and " );
594 mText += "<IMG src=\"" + NOiconPath + "\"> )"; 594 mText += "<IMG src=\"" + NOiconPath + "\"> )";
595 mText += "<br>\n"; 595 mText += "<br>\n";
596 596
597 597
598 } 598 }
599 if ( a_count_nr > 1 ) { 599 if ( a_count_nr > 1 ) {
600 mText += "<a href=\"mailto:RSVP\">"; 600 mText += "<a href=\"mailto:RSVP\">";
601 mText += i18n( "Mail to selected" ); 601 mText += i18n( "Mail to selected" );
602 mText += "</a> ( "; 602 mText += "</a> ( ";
603 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); 603 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath );
604 mText += "<br>\n"; 604 mText += "<br>\n";
605 } 605 }
606 } 606 }
607 607
608} 608}
609void KOEventViewer::appendJournal(Journal *jour, int mode ) 609void KOEventViewer::appendJournal(Journal *jour, int mode )
610{ 610{
611 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 611 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
612 if (mode == 0 ) { 612 if (mode == 0 ) {
613 addTag("h2",i18n("Journal from: ")); 613 addTag("h2",i18n("Journal from: "));
614 } 614 }
615 else { 615 else {
616 if ( mode == 1 ) { 616 if ( mode == 1 ) {
617 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 617 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
618 } else { 618 } else {
619 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 619 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
620 } 620 }
621 } 621 }
622 topLevelWidget()->setCaption("Journal Viewer"); 622 topLevelWidget()->setCaption("Journal Viewer");
623 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 623 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
624 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 624 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
625 if (!jour->description().isEmpty()) { 625 if (!jour->description().isEmpty()) {
626 addTag("p",jour->description()); 626 addTag("p",deTag(jour->description()));
627 } 627 }
628 setText(mText); 628 setText(mText);
629} 629}
630 630
631void KOEventViewer::formatReadOnly(Incidence *event) 631void KOEventViewer::formatReadOnly(Incidence *event)
632{ 632{
633 if (event->isReadOnly()) { 633 if (event->isReadOnly()) {
634 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 634 addTag("p","<em>(" + i18n("read-only") + ")</em>");
635 } 635 }
636} 636}
637void KOEventViewer::setSyncMode( bool b ) 637void KOEventViewer::setSyncMode( bool b )
638{ 638{
639 mSyncMode = b; 639 mSyncMode = b;
640} 640}
641 641
642
643void KOEventViewer::setTodo(Todo *event, bool clearV ) 642void KOEventViewer::setTodo(Todo *event, bool clearV )
644{ 643{
645 if ( clearV ) 644 if ( clearV )
646 clearEvents(); 645 clearEvents();
647 if ( mSyncMode ) { 646 if ( mSyncMode ) {
648 if ( clearV ) 647 if ( clearV )
649 appendTodo(event,1 ); 648 appendTodo(event,1 );
650 else 649 else
651 appendTodo(event,2); 650 appendTodo(event,2);
652 } else 651 } else
653 appendTodo(event); 652 appendTodo(event);
654} 653}
655void KOEventViewer::setJournal(Journal *event, bool clearV ) 654void KOEventViewer::setJournal(Journal *event, bool clearV )
656{ 655{
657 if ( clearV ) 656 if ( clearV )
658 clearEvents(); 657 clearEvents();
659 if ( mSyncMode ) { 658 if ( mSyncMode ) {
660 if ( clearV ) 659 if ( clearV )
661 appendJournal(event, 1); 660 appendJournal(event, 1);
662 else 661 else
663 appendJournal(event, 2); 662 appendJournal(event, 2);
664 } else 663 } else
665 appendJournal(event); 664 appendJournal(event);
666} 665}
667 666
668void KOEventViewer::setEvent(Event *event) 667void KOEventViewer::setEvent(Event *event)
669{ 668{
670 clearEvents(); 669 clearEvents();
671 if ( mSyncMode ) 670 if ( mSyncMode )
672 appendEvent(event, 1); 671 appendEvent(event, 1);
673 else 672 else
674 appendEvent(event); 673 appendEvent(event);
675} 674}
676 675
677void KOEventViewer::addEvent(Event *event) 676void KOEventViewer::addEvent(Event *event)
678{ 677{
679 if ( mSyncMode ) 678 if ( mSyncMode )
680 appendEvent(event, 2); 679 appendEvent(event, 2);
681 else 680 else
682 appendEvent(event); 681 appendEvent(event);
683} 682}
684 683
685void KOEventViewer::clearEvents(bool now) 684void KOEventViewer::clearEvents(bool now)
686{ 685{
687 mText = ""; 686 mText = "";
688 if (now) setText(mText); 687 if (now) setText(mText);
689} 688}
690 689
691void KOEventViewer::addText(QString text) 690void KOEventViewer::addText(QString text)
692{ 691{
693 mText.append(text); 692 mText.append(text);
694 setText(mText); 693 setText(mText);
695} 694}
695QString KOEventViewer::deTag(QString text)
696{
697#if QT_VERSION >= 0x030000
698 text.replace( '<' , "&lt;" );
699 text.replace( '>' , "&gt;" );
700#else
701 if ( text.find ('<') > 0 ) {
702 text.replace( QRegExp("<") , "&lt;" );
703 }
704 if ( text.find ('>') > 0 ) {
705 text.replace( QRegExp(">") , "&gt;" );
706 }
707#endif
708 return text;
709}
696void KOEventViewer::keyPressEvent ( QKeyEvent * e ) 710void KOEventViewer::keyPressEvent ( QKeyEvent * e )
697{ 711{
698 switch ( e->key() ) { 712 switch ( e->key() ) {
699 case Qt::Key_Return: 713 case Qt::Key_Return:
700 case Qt::Key_Enter : 714 case Qt::Key_Enter :
701 e->ignore(); 715 e->ignore();
702 break; 716 break;
703 default: 717 default:
704 QTextBrowser::keyPressEvent ( e ); 718 QTextBrowser::keyPressEvent ( e );
705 break; 719 break;
706 } 720 }
707} 721}
diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h
index 2d4a08e..47cc5e9 100644
--- a/korganizer/koeventviewer.h
+++ b/korganizer/koeventviewer.h
@@ -1,76 +1,77 @@
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#ifndef KOEVENTVIEWER_H 19#ifndef KOEVENTVIEWER_H
20#define KOEVENTVIEWER_H 20#define KOEVENTVIEWER_H
21// 21//
22// Viewer widget for events. 22// Viewer widget for events.
23// 23//
24 24
25#include <qtextbrowser.h> 25#include <qtextbrowser.h>
26 26
27#include <libkcal/event.h> 27#include <libkcal/event.h>
28#include <libkcal/journal.h> 28#include <libkcal/journal.h>
29 29
30 30
31using namespace KCal; 31using namespace KCal;
32 32
33class KOEventViewer : public QTextBrowser { 33class KOEventViewer : public QTextBrowser {
34 Q_OBJECT 34 Q_OBJECT
35 public: 35 public:
36 KOEventViewer(QWidget *parent=0,const char *name=0); 36 KOEventViewer(QWidget *parent=0,const char *name=0);
37 virtual ~KOEventViewer(); 37 virtual ~KOEventViewer();
38 38
39 void setSource(const QString &); 39 void setSource(const QString &);
40 void setEvent(Event *event); 40 void setEvent(Event *event);
41 void addEvent(Event *event); 41 void addEvent(Event *event);
42 void setTodo(Todo *event, bool clearV = true ); 42 void setTodo(Todo *event, bool clearV = true );
43 void setJournal(Journal *jour, bool clearV = true ); 43 void setJournal(Journal *jour, bool clearV = true );
44 44
45 void appendEvent(Event *event, int mode = 0 ); 45 void appendEvent(Event *event, int mode = 0 );
46 void appendTodo(Todo *event, int mode = 0 ); 46 void appendTodo(Todo *event, int mode = 0 );
47 void appendJournal(Journal *jour, int mode = 0 ); 47 void appendJournal(Journal *jour, int mode = 0 );
48 48
49 void clearEvents(bool now=false); 49 void clearEvents(bool now=false);
50 50
51 void addText(QString text); 51 void addText(QString text);
52 void setSyncMode( bool ); 52 void setSyncMode( bool );
53 void setColorMode( int ); 53 void setColorMode( int );
54 void mailToAttendees( bool all ); 54 void mailToAttendees( bool all );
55 55
56 protected: 56 protected:
57 int mColorMode; 57 int mColorMode;
58 void addTag(const QString & tag,const QString & text); 58 void addTag(const QString & tag,const QString & text);
59 59
60 void formatCategories(Incidence *event); 60 void formatCategories(Incidence *event);
61 void formatAttendees(Incidence *event); 61 void formatAttendees(Incidence *event);
62 void formatReadOnly(Incidence *event); 62 void formatReadOnly(Incidence *event);
63 void keyPressEvent ( QKeyEvent * e ); 63 void keyPressEvent ( QKeyEvent * e );
64 64
65 private: 65 private:
66 QTextBrowser *mEventTextView; 66 QTextBrowser *mEventTextView;
67 bool mSyncMode; 67 bool mSyncMode;
68 QString deTag(QString text);
68 69
69 QString mText; 70 QString mText;
70 QString mMailSubject; 71 QString mMailSubject;
71 Incidence* mCurrentIncidence; 72 Incidence* mCurrentIncidence;
72 signals: 73 signals:
73 void launchaddressbook(QString uid); 74 void launchaddressbook(QString uid);
74}; 75};
75 76
76#endif 77#endif
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 1751ae3..57a9ede 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -1,378 +1,393 @@
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#define size count 7#define size count
8#endif 8#endif
9 9
10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; 10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
11static KStaticDeleter<KIncidenceFormatter> insd; 11static KStaticDeleter<KIncidenceFormatter> insd;
12 12
13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) 13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified )
14{ 14{
15// #ifndef QT_NO_INPUTDIALOG 15// #ifndef QT_NO_INPUTDIALOG
16// return QInputDialog::getItem( caption, label, items, current, editable ); 16// return QInputDialog::getItem( caption, label, items, current, editable );
17// #else 17// #else
18// return QString::null; 18// return QString::null;
19// #endif 19// #endif
20 mDetails = details; 20 mDetails = details;
21 mCreated = created ; 21 mCreated = created ;
22 mModified = modified; 22 mModified = modified;
23 mText = ""; 23 mText = "";
24 if ( inc->type() == "Event" ) 24 if ( inc->type() == "Event" )
25 setEvent((Event *) inc ); 25 setEvent((Event *) inc );
26 else if ( inc->type() == "Todo" ) 26 else if ( inc->type() == "Todo" )
27 setTodo((Todo *) inc ); 27 setTodo((Todo *) inc );
28 return mText; 28 return mText;
29} 29}
30 30
31KIncidenceFormatter* KIncidenceFormatter::instance() 31KIncidenceFormatter* KIncidenceFormatter::instance()
32{ 32{
33 if (!mInstance) { 33 if (!mInstance) {
34 mInstance = insd.setObject(new KIncidenceFormatter()); 34 mInstance = insd.setObject(new KIncidenceFormatter());
35 } 35 }
36 return mInstance; 36 return mInstance;
37} 37}
38KIncidenceFormatter::~KIncidenceFormatter() 38KIncidenceFormatter::~KIncidenceFormatter()
39{ 39{
40 if (mInstance == this) 40 if (mInstance == this)
41 mInstance = insd.setObject(0); 41 mInstance = insd.setObject(0);
42 //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); 42 //qDebug("KIncidenceFormatter::~KIncidenceFormatter ");
43} 43}
44KIncidenceFormatter::KIncidenceFormatter() 44KIncidenceFormatter::KIncidenceFormatter()
45{ 45{
46 mColorMode = 0; 46 mColorMode = 0;
47} 47}
48void KIncidenceFormatter::setEvent(Event *event) 48void KIncidenceFormatter::setEvent(Event *event)
49{ 49{
50 int mode = 0; 50 int mode = 0;
51 mCurrentIncidence = event; 51 mCurrentIncidence = event;
52 bool shortDate = true; 52 bool shortDate = true;
53 if ( mode == 0 ) { 53 if ( mode == 0 ) {
54 addTag("h3",event->summary()); 54 addTag("h3",deTag(event->summary()));
55 } 55 }
56 else { 56 else {
57 if ( mColorMode == 1 ) { 57 if ( mColorMode == 1 ) {
58 mText +="<font color=\"#00A000\">"; 58 mText +="<font color=\"#00A000\">";
59 } 59 }
60 if ( mColorMode == 2 ) { 60 if ( mColorMode == 2 ) {
61 mText +="<font color=\"#C00000\">"; 61 mText +="<font color=\"#C00000\">";
62 } 62 }
63 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 63 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
64 if ( mode == 1 ) { 64 if ( mode == 1 ) {
65 addTag("h2",i18n( "Local: " ) +event->summary()); 65 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
66 } else { 66 } else {
67 addTag("h2",i18n( "Remote: " ) +event->summary()); 67 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
68 } 68 }
69 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 69 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
70 if ( mColorMode ) 70 if ( mColorMode )
71 mText += "</font>"; 71 mText += "</font>";
72 } 72 }
73 if (event->cancelled ()) { 73 if (event->cancelled ()) {
74 mText +="<font color=\"#B00000\">"; 74 mText +="<font color=\"#B00000\">";
75 addTag("i",i18n("This event has been cancelled!")); 75 addTag("i",i18n("This event has been cancelled!"));
76 mText.append("<br>"); 76 mText.append("<br>");
77 mText += "</font>"; 77 mText += "</font>";
78 } 78 }
79 if (!event->location().isEmpty()) { 79 if (!event->location().isEmpty()) {
80 addTag("b",i18n("Location: ")); 80 addTag("b",i18n("Location: "));
81 mText.append(event->location()+"<br>"); 81 mText.append(deTag(event->location())+"<br>");
82 } 82 }
83 if (event->doesFloat()) { 83 if (event->doesFloat()) {
84 if (event->isMultiDay()) { 84 if (event->isMultiDay()) {
85 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 85 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
86 .arg(event->dtStartDateStr(shortDate)) 86 .arg(event->dtStartDateStr(shortDate))
87 .arg(event->dtEndDateStr(shortDate))); 87 .arg(event->dtEndDateStr(shortDate)));
88 } else { 88 } else {
89 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 89 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
90 } 90 }
91 } else { 91 } else {
92 if (event->isMultiDay()) { 92 if (event->isMultiDay()) {
93 mText.append(i18n("<p><b>From:</b> %1</p> ") 93 mText.append(i18n("<p><b>From:</b> %1</p> ")
94 .arg(event->dtStartStr( shortDate))); 94 .arg(event->dtStartStr( shortDate)));
95 mText.append(i18n("<p><b>To:</b> %1</p>") 95 mText.append(i18n("<p><b>To:</b> %1</p>")
96 .arg(event->dtEndStr(shortDate))); 96 .arg(event->dtEndStr(shortDate)));
97 } else { 97 } else {
98 mText.append(i18n("<p><b>On:</b> %1</p> ") 98 mText.append(i18n("<p><b>On:</b> %1</p> ")
99 .arg(event->dtStartDateStr( shortDate ))); 99 .arg(event->dtStartDateStr( shortDate )));
100 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 100 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
101 .arg(event->dtStartTimeStr()) 101 .arg(event->dtStartTimeStr())
102 .arg(event->dtEndTimeStr())); 102 .arg(event->dtEndTimeStr()));
103 } 103 }
104 } 104 }
105 105
106 if (event->recurrence()->doesRecur()) { 106 if (event->recurrence()->doesRecur()) {
107 107
108 QString recurText = event->recurrence()->recurrenceText(); 108 QString recurText = event->recurrence()->recurrenceText();
109 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 109 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
110 110
111 bool ok; 111 bool ok;
112 QDate start = QDate::currentDate(); 112 QDate start = QDate::currentDate();
113 QDateTime next; 113 QDateTime next;
114 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 114 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
115 if ( ok ) { 115 if ( ok ) {
116 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 116 addTag("p",i18n("<b>Next recurrence is on:</b>") );
117 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 117 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
118 118
119 } else { 119 } else {
120 bool last; 120 bool last;
121 QDate nextd; 121 QDate nextd;
122 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 122 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
123 if ( last ) { 123 if ( last ) {
124 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 124 addTag("p",i18n("<b>Last recurrence was on:</b>") );
125 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 125 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
126 } 126 }
127 } 127 }
128 } 128 }
129 129
130 130
131 if (event->isAlarmEnabled()) { 131 if (event->isAlarmEnabled()) {
132 Alarm *alarm =event->alarms().first() ; 132 Alarm *alarm =event->alarms().first() ;
133 QDateTime t = alarm->time(); 133 QDateTime t = alarm->time();
134 int min = t.secsTo( event->dtStart() )/60; 134 int min = t.secsTo( event->dtStart() )/60;
135 QString s =i18n("(%1 min before)").arg( min ); 135 QString s =i18n("(%1 min before)").arg( min );
136 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); 136 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
137 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 137 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
138 //addTag("p",s); 138 //addTag("p",s);
139 } 139 }
140 140
141 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 141 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
142 // mText.append(event->secrecyStr()+"<br>"); 142 // mText.append(event->secrecyStr()+"<br>");
143 formatCategories(event); 143 formatCategories(event);
144 if ( mDetails ) { 144 if ( mDetails ) {
145 if (!event->description().isEmpty()) { 145 if (!event->description().isEmpty()) {
146 addTag("p",i18n("<b>Details: </b>")); 146 addTag("p",i18n("<b>Details: </b>"));
147 addTag("p",event->description()); 147 addTag("p",deTag(event->description()));
148 } 148 }
149 } 149 }
150 150
151 formatReadOnly(event); 151 formatReadOnly(event);
152 formatAttendees(event); 152 formatAttendees(event);
153 153
154 if ( mCreated ) { 154 if ( mCreated ) {
155 addTag("p",i18n("<b>Created: ") +" </b>"); 155 addTag("p",i18n("<b>Created: ") +" </b>");
156 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 156 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
157 157
158 } 158 }
159 if ( mModified ) { 159 if ( mModified ) {
160 addTag("p",i18n("<b>Last modified: ") +" </b>"); 160 addTag("p",i18n("<b>Last modified: ") +" </b>");
161 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 161 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
162 162
163 } 163 }
164 164
165} 165}
166 166
167void KIncidenceFormatter::setTodo(Todo *event ) 167void KIncidenceFormatter::setTodo(Todo *event )
168{ 168{
169 int mode = 0; 169 int mode = 0;
170 mCurrentIncidence = event; 170 mCurrentIncidence = event;
171 bool shortDate = true; 171 bool shortDate = true;
172 if (mode == 0 ) 172 if (mode == 0 )
173 addTag("h3",event->summary()); 173 addTag("h3",deTag(event->summary()));
174 else { 174 else {
175 if ( mColorMode == 1 ) { 175 if ( mColorMode == 1 ) {
176 mText +="<font color=\"#00A000\">"; 176 mText +="<font color=\"#00A000\">";
177 } 177 }
178 if ( mColorMode == 2 ) { 178 if ( mColorMode == 2 ) {
179 mText +="<font color=\"#B00000\">"; 179 mText +="<font color=\"#B00000\">";
180 } 180 }
181 if ( mode == 1 ) { 181 if ( mode == 1 ) {
182 addTag("h2",i18n( "Local: " ) +event->summary()); 182 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
183 } else { 183 } else {
184 addTag("h2",i18n( "Remote: " ) +event->summary()); 184 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
185 } 185 }
186 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 186 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
187 if ( mColorMode ) 187 if ( mColorMode )
188 mText += "</font>"; 188 mText += "</font>";
189 } 189 }
190 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 190 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
191 mText +="<font color=\"#B00000\">"; 191 mText +="<font color=\"#B00000\">";
192 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); 192 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) );
193 mText += "</font>"; 193 mText += "</font>";
194 } else { 194 } else {
195 mText.append(i18n("<p><i>%1 % completed</i></p>") 195 mText.append(i18n("<p><i>%1 % completed</i></p>")
196 .arg(event->percentComplete())); 196 .arg(event->percentComplete()));
197 } 197 }
198 if (event->cancelled ()) { 198 if (event->cancelled ()) {
199 mText +="<font color=\"#B00000\">"; 199 mText +="<font color=\"#B00000\">";
200 addTag("i",i18n("This todo has been cancelled!")); 200 addTag("i",i18n("This todo has been cancelled!"));
201 mText.append("<br>"); 201 mText.append("<br>");
202 mText += "</font>"; 202 mText += "</font>";
203 } 203 }
204 204
205 if (!event->location().isEmpty()) { 205 if (!event->location().isEmpty()) {
206 addTag("b",i18n("Location: ")); 206 addTag("b",i18n("Location: "));
207 mText.append(event->location()+"<br>"); 207 mText.append(deTag(event->location())+"<br>");
208 } 208 }
209 209
210 if (event->recurrence()->doesRecur()) { 210 if (event->recurrence()->doesRecur()) {
211 211
212 QString recurText = event->recurrence()->recurrenceText(); 212 QString recurText = event->recurrence()->recurrenceText();
213 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); 213 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>");
214 } 214 }
215 215
216 if (event->hasStartDate()) { 216 if (event->hasStartDate()) {
217 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); 217 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate)));
218 } 218 }
219 219
220 220
221 if (event->hasDueDate()) { 221 if (event->hasDueDate()) {
222 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); 222 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
223 } 223 }
224 mText.append(i18n("<p><b>Priority:</b> %2</p>") 224 mText.append(i18n("<p><b>Priority:</b> %2</p>")
225 .arg(QString::number(event->priority()))); 225 .arg(QString::number(event->priority())));
226 226
227 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 227 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
228 formatCategories(event); 228 formatCategories(event);
229 if ( mDetails ) { 229 if ( mDetails ) {
230 if (!event->description().isEmpty()) { 230 if (!event->description().isEmpty()) {
231 addTag("p",i18n("<b>Details: </b>")); 231 addTag("p",i18n("<b>Details: </b>"));
232 addTag("p",event->description()); 232 addTag("p",deTag(event->description()));
233 } 233 }
234 } 234 }
235 formatReadOnly(event); 235 formatReadOnly(event);
236 formatAttendees(event); 236 formatAttendees(event);
237 if ( mCreated ) { 237 if ( mCreated ) {
238 addTag("p",i18n("<b>Created: ") +" </b>"); 238 addTag("p",i18n("<b>Created: ") +" </b>");
239 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 239 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
240 240
241 } 241 }
242 if ( mModified ) { 242 if ( mModified ) {
243 addTag("p",i18n("<b>Last modified: ") +" </b>"); 243 addTag("p",i18n("<b>Last modified: ") +" </b>");
244 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 244 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
245 245
246 } 246 }
247} 247}
248 248
249void KIncidenceFormatter::setJournal(Journal* ) 249void KIncidenceFormatter::setJournal(Journal* )
250{ 250{
251 251
252} 252}
253 253
254void KIncidenceFormatter::formatCategories(Incidence *event) 254void KIncidenceFormatter::formatCategories(Incidence *event)
255{ 255{
256 if (!event->categoriesStr().isEmpty()) { 256 if (!event->categoriesStr().isEmpty()) {
257 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); 257 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() );
258 //mText.append(event->categoriesStr()); 258 //mText.append(event->categoriesStr());
259 } 259 }
260} 260}
261void KIncidenceFormatter::addTag(const QString & tag,const QString & text) 261void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
262{ 262{
263 int number=text.contains("\n"); 263 int number=text.contains("\n");
264 QString str = "<" + tag + ">"; 264 QString str = "<" + tag + ">";
265 QString tmpText=text; 265 QString tmpText=text;
266 QString tmpStr=str; 266 QString tmpStr=str;
267 if(number !=-1) 267 if(number !=-1)
268 { 268 {
269 if (number > 0) { 269 if (number > 0) {
270 int pos=0; 270 int pos=0;
271 QString tmp; 271 QString tmp;
272 for(int i=0;i<=number;i++) { 272 for(int i=0;i<=number;i++) {
273 pos=tmpText.find("\n"); 273 pos=tmpText.find("\n");
274 tmp=tmpText.left(pos); 274 tmp=tmpText.left(pos);
275 tmpText=tmpText.right(tmpText.length()-pos-1); 275 tmpText=tmpText.right(tmpText.length()-pos-1);
276 tmpStr+=tmp+"<br>"; 276 tmpStr+=tmp+"<br>";
277 } 277 }
278 } 278 }
279 else tmpStr += tmpText; 279 else tmpStr += tmpText;
280 tmpStr+="</" + tag + ">"; 280 tmpStr+="</" + tag + ">";
281 mText.append(tmpStr); 281 mText.append(tmpStr);
282 } 282 }
283 else 283 else
284 { 284 {
285 str += text + "</" + tag + ">"; 285 str += text + "</" + tag + ">";
286 mText.append(str); 286 mText.append(str);
287 } 287 }
288} 288}
289 289
290void KIncidenceFormatter::formatAttendees(Incidence *event) 290void KIncidenceFormatter::formatAttendees(Incidence *event)
291{ 291{
292 QPtrList<Attendee> attendees = event->attendees(); 292 QPtrList<Attendee> attendees = event->attendees();
293 if (attendees.count()) { 293 if (attendees.count()) {
294 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 294 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
295 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 295 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
296 addTag("h3",i18n("Organizer")); 296 addTag("h3",i18n("Organizer"));
297 mText.append("<ul><li>"); 297 mText.append("<ul><li>");
298#if 0 298#if 0
299 //ndef KORG_NOKABC 299 //ndef KORG_NOKABC
300 300
301 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 301 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
302 KABC::Addressee::List addressList; 302 KABC::Addressee::List addressList;
303 addressList = add_book->findByEmail(event->organizer()); 303 addressList = add_book->findByEmail(event->organizer());
304 KABC::Addressee o = addressList.first(); 304 KABC::Addressee o = addressList.first();
305 if (!o.isEmpty() && addressList.size()<2) { 305 if (!o.isEmpty() && addressList.size()<2) {
306 mText += "<a href=\"uid:" + o.uid() + "\">"; 306 mText += "<a href=\"uid:" + o.uid() + "\">";
307 mText += o.formattedName(); 307 mText += o.formattedName();
308 mText += "</a>\n"; 308 mText += "</a>\n";
309 } else { 309 } else {
310 mText.append(event->organizer()); 310 mText.append(event->organizer());
311 } 311 }
312#else 312#else
313 mText.append(event->organizer()); 313 mText.append(event->organizer());
314#endif 314#endif
315 if (iconPath) { 315 if (iconPath) {
316 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 316 mText += " <a href=\"mailto:" + event->organizer() + "\">";
317 mText += "<IMG src=\"" + iconPath + "\">"; 317 mText += "<IMG src=\"" + iconPath + "\">";
318 mText += "</a>\n"; 318 mText += "</a>\n";
319 } 319 }
320 mText.append("</li></ul>"); 320 mText.append("</li></ul>");
321 321
322 addTag("h3",i18n("Attendees")); 322 addTag("h3",i18n("Attendees"));
323 Attendee *a; 323 Attendee *a;
324 mText.append("<ul>"); 324 mText.append("<ul>");
325 for(a=attendees.first();a;a=attendees.next()) { 325 for(a=attendees.first();a;a=attendees.next()) {
326#if 0 326#if 0
327//ndef KORG_NOKABC 327//ndef KORG_NOKABC
328 if (a->name().isEmpty()) { 328 if (a->name().isEmpty()) {
329 addressList = add_book->findByEmail(a->email()); 329 addressList = add_book->findByEmail(a->email());
330 KABC::Addressee o = addressList.first(); 330 KABC::Addressee o = addressList.first();
331 if (!o.isEmpty() && addressList.size()<2) { 331 if (!o.isEmpty() && addressList.size()<2) {
332 mText += "<a href=\"uid:" + o.uid() + "\">"; 332 mText += "<a href=\"uid:" + o.uid() + "\">";
333 mText += o.formattedName(); 333 mText += o.formattedName();
334 mText += "</a>\n"; 334 mText += "</a>\n";
335 } else { 335 } else {
336 mText += "<li>"; 336 mText += "<li>";
337 mText.append(a->email()); 337 mText.append(a->email());
338 mText += "\n"; 338 mText += "\n";
339 } 339 }
340 } else { 340 } else {
341 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 341 mText += "<li><a href=\"uid:" + a->uid() + "\">";
342 if (!a->name().isEmpty()) mText += a->name(); 342 if (!a->name().isEmpty()) mText += a->name();
343 else mText += a->email(); 343 else mText += a->email();
344 mText += "</a>\n"; 344 mText += "</a>\n";
345 } 345 }
346#else 346#else
347 //qDebug("nokabc "); 347 //qDebug("nokabc ");
348 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 348 mText += "<li><a href=\"uid:" + a->uid() + "\">";
349 if (!a->name().isEmpty()) mText += a->name(); 349 if (!a->name().isEmpty()) mText += a->name();
350 else mText += a->email(); 350 else mText += a->email();
351 mText += "</a>\n"; 351 mText += "</a>\n";
352#endif 352#endif
353 353
354 if (!a->email().isEmpty()) { 354 if (!a->email().isEmpty()) {
355 if (iconPath) { 355 if (iconPath) {
356 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 356 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
357 if ( a->RSVP() ) 357 if ( a->RSVP() )
358 mText += "<IMG src=\"" + iconPath + "\">"; 358 mText += "<IMG src=\"" + iconPath + "\">";
359 else 359 else
360 mText += "<IMG src=\"" + NOiconPath + "\">"; 360 mText += "<IMG src=\"" + NOiconPath + "\">";
361 mText += "</a>\n"; 361 mText += "</a>\n";
362 } 362 }
363 } 363 }
364 if (a->status() != Attendee::NeedsAction ) 364 if (a->status() != Attendee::NeedsAction )
365 mText +="[" + a->statusStr() + "] "; 365 mText +="[" + a->statusStr() + "] ";
366 if (a->role() == Attendee::Chair ) 366 if (a->role() == Attendee::Chair )
367 mText +="(" + a->roleStr().left(1) + ".)"; 367 mText +="(" + a->roleStr().left(1) + ".)";
368 } 368 }
369 mText.append("</li></ul>"); 369 mText.append("</li></ul>");
370 } 370 }
371} 371}
372 372
373void KIncidenceFormatter::formatReadOnly(Incidence *event) 373void KIncidenceFormatter::formatReadOnly(Incidence *event)
374{ 374{
375 if (event->isReadOnly()) { 375 if (event->isReadOnly()) {
376 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 376 addTag("p","<em>(" + i18n("read-only") + ")</em>");
377 } 377 }
378} 378}
379QString KIncidenceFormatter::deTag(QString text)
380{
381#if QT_VERSION >= 0x030000
382 text.replace( '<' , "&lt;" );
383 text.replace( '>' , "&gt;" );
384#else
385 if ( text.find ('<') > 0 ) {
386 text.replace( QRegExp("<") , "&lt;" );
387 }
388 if ( text.find ('>') > 0 ) {
389 text.replace( QRegExp(">") , "&gt;" );
390 }
391#endif
392 return text;
393}
diff --git a/libkcal/kincidenceformatter.h b/libkcal/kincidenceformatter.h
index 068e6d2..b5603e0 100644
--- a/libkcal/kincidenceformatter.h
+++ b/libkcal/kincidenceformatter.h
@@ -1,43 +1,44 @@
1#ifndef KINCIDENCENFORMATTER_H 1#ifndef KINCIDENCENFORMATTER_H
2#define KINCIDENCENFORMATTER_H 2#define KINCIDENCENFORMATTER_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qobject.h> 5#include <qobject.h>
6 6
7#include "incidence.h" 7#include "incidence.h"
8#include "event.h" 8#include "event.h"
9#include "todo.h" 9#include "todo.h"
10#include "journal.h" 10#include "journal.h"
11 11
12using namespace KCal; 12using namespace KCal;
13 13
14class KIncidenceFormatter : public QObject 14class KIncidenceFormatter : public QObject
15{ 15{
16 public: 16 public:
17 static KIncidenceFormatter* instance(); 17 static KIncidenceFormatter* instance();
18 KIncidenceFormatter(); 18 KIncidenceFormatter();
19 ~KIncidenceFormatter(); 19 ~KIncidenceFormatter();
20 QString getFormattedText( Incidence * inc , bool details = false, bool created = false, bool modified = false ); 20 QString getFormattedText( Incidence * inc , bool details = false, bool created = false, bool modified = false );
21 21
22 void setEvent(Event *event); 22 void setEvent(Event *event);
23 void setTodo(Todo *event ); 23 void setTodo(Todo *event );
24 void setJournal(Journal* ); 24 void setJournal(Journal* );
25 25
26 protected: 26 protected:
27 int mColorMode; 27 int mColorMode;
28 void addTag(const QString & tag,const QString & text); 28 void addTag(const QString & tag,const QString & text);
29 29
30 void formatCategories(Incidence *event); 30 void formatCategories(Incidence *event);
31 void formatAttendees(Incidence *event); 31 void formatAttendees(Incidence *event);
32 void formatReadOnly(Incidence *event); 32 void formatReadOnly(Incidence *event);
33 33
34 private: 34 private:
35 QString deTag(QString text);
35 bool mSyncMode; 36 bool mSyncMode;
36 bool mDetails, mCreated ,mModified; 37 bool mDetails, mCreated ,mModified;
37 38
38 QString mText; 39 QString mText;
39 Incidence* mCurrentIncidence; 40 Incidence* mCurrentIncidence;
40 static KIncidenceFormatter* mInstance; 41 static KIncidenceFormatter* mInstance;
41}; 42};
42 43
43#endif 44#endif