summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-03-10 14:36:13 (UTC)
committer zautrix <zautrix>2005-03-10 14:36:13 (UTC)
commit34f5a1b758adb98c466ae8e45c9d980d62dfc544 (patch) (unidiff)
tree1ba10eac4df592da4b284bae029a864e40314d18 /libkcal
parentb96161e4dd7fc19eea87257c2455b85420dad35a (diff)
downloadkdepimpi-34f5a1b758adb98c466ae8e45c9d980d62dfc544.zip
kdepimpi-34f5a1b758adb98c466ae8e45c9d980d62dfc544.tar.gz
kdepimpi-34f5a1b758adb98c466ae8e45c9d980d62dfc544.tar.bz2
htmal tag fix
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/kincidenceformatter.cpp35
-rw-r--r--libkcal/kincidenceformatter.h1
2 files changed, 26 insertions, 10 deletions
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 1751ae3..57a9ede 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -48,26 +48,26 @@ KIncidenceFormatter::KIncidenceFormatter()
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 ()) {
@@ -75,13 +75,13 @@ void KIncidenceFormatter::setEvent(Event *event)
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)));
@@ -141,13 +141,13 @@ void KIncidenceFormatter::setEvent(Event *event)
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
@@ -167,24 +167,24 @@ void KIncidenceFormatter::setEvent(Event *event)
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() ) {
@@ -201,13 +201,13 @@ void KIncidenceFormatter::setTodo(Todo *event )
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>");
@@ -226,13 +226,13 @@ void KIncidenceFormatter::setTodo(Todo *event )
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>");
@@ -373,6 +373,21 @@ void KIncidenceFormatter::formatAttendees(Incidence *event)
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
@@ -29,12 +29,13 @@ class KIncidenceFormatter : public QObject
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;