author | zautrix <zautrix> | 2005-03-10 14:36:13 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-10 14:36:13 (UTC) |
commit | 34f5a1b758adb98c466ae8e45c9d980d62dfc544 (patch) (unidiff) | |
tree | 1ba10eac4df592da4b284bae029a864e40314d18 /libkcal | |
parent | b96161e4dd7fc19eea87257c2455b85420dad35a (diff) | |
download | kdepimpi-34f5a1b758adb98c466ae8e45c9d980d62dfc544.zip kdepimpi-34f5a1b758adb98c466ae8e45c9d980d62dfc544.tar.gz kdepimpi-34f5a1b758adb98c466ae8e45c9d980d62dfc544.tar.bz2 |
htmal tag fix
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 35 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.h | 1 |
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 | |||
@@ -6,275 +6,275 @@ | |||
6 | #include <kabc/stdaddressbook.h> | 6 | #include <kabc/stdaddressbook.h> |
7 | #define size count | 7 | #define size count |
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; | 10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; |
11 | static KStaticDeleter<KIncidenceFormatter> insd; | 11 | static KStaticDeleter<KIncidenceFormatter> insd; |
12 | 12 | ||
13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) | 13 | QString 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 | ||
31 | KIncidenceFormatter* KIncidenceFormatter::instance() | 31 | KIncidenceFormatter* 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 | } |
38 | KIncidenceFormatter::~KIncidenceFormatter() | 38 | KIncidenceFormatter::~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 | } |
44 | KIncidenceFormatter::KIncidenceFormatter() | 44 | KIncidenceFormatter::KIncidenceFormatter() |
45 | { | 45 | { |
46 | mColorMode = 0; | 46 | mColorMode = 0; |
47 | } | 47 | } |
48 | void KIncidenceFormatter::setEvent(Event *event) | 48 | void 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 | ||
167 | void KIncidenceFormatter::setTodo(Todo *event ) | 167 | void 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 | ||
249 | void KIncidenceFormatter::setJournal(Journal* ) | 249 | void KIncidenceFormatter::setJournal(Journal* ) |
250 | { | 250 | { |
251 | 251 | ||
252 | } | 252 | } |
253 | 253 | ||
254 | void KIncidenceFormatter::formatCategories(Incidence *event) | 254 | void 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 | } |
261 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 261 | void 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 + ">"; |
@@ -331,48 +331,63 @@ void KIncidenceFormatter::formatAttendees(Incidence *event) | |||
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 | ||
373 | void KIncidenceFormatter::formatReadOnly(Incidence *event) | 373 | void 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 | } |
379 | QString KIncidenceFormatter::deTag(QString text) | ||
380 | { | ||
381 | #if QT_VERSION >= 0x030000 | ||
382 | text.replace( '<' , "<" ); | ||
383 | text.replace( '>' , ">" ); | ||
384 | #else | ||
385 | if ( text.find ('<') > 0 ) { | ||
386 | text.replace( QRegExp("<") , "<" ); | ||
387 | } | ||
388 | if ( text.find ('>') > 0 ) { | ||
389 | text.replace( QRegExp(">") , ">" ); | ||
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 | ||
12 | using namespace KCal; | 12 | using namespace KCal; |
13 | 13 | ||
14 | class KIncidenceFormatter : public QObject | 14 | class 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 |