-rw-r--r-- | libkcal/kincidenceformatter.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index f8f40f1..4dfe16a 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -1,425 +1,427 @@ | |||
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 | ||
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->typeID() == eventID ) | 24 | if ( inc->typeID() == eventID ) |
25 | setEvent((Event *) inc ); | 25 | setEvent((Event *) inc ); |
26 | else if ( inc->typeID() == todoID ) | 26 | else if ( inc->typeID() == todoID ) |
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",deTag(event->summary())); | 54 | addTag("h3",deTag(event->summary())); |
55 | formatReadOnly(event); | 55 | formatReadOnly(event); |
56 | } | 56 | } |
57 | else { | 57 | else { |
58 | if ( mColorMode == 1 ) { | 58 | if ( mColorMode == 1 ) { |
59 | mText +="<font color=\"#00A000\">"; | 59 | mText +="<font color=\"#00A000\">"; |
60 | } | 60 | } |
61 | if ( mColorMode == 2 ) { | 61 | if ( mColorMode == 2 ) { |
62 | mText +="<font color=\"#C00000\">"; | 62 | mText +="<font color=\"#C00000\">"; |
63 | } | 63 | } |
64 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 64 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
65 | if ( mode == 1 ) { | 65 | if ( mode == 1 ) { |
66 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 66 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
67 | } else { | 67 | } else { |
68 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 68 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
69 | } | 69 | } |
70 | formatReadOnly(event); | 70 | formatReadOnly(event); |
71 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 71 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
72 | if ( mColorMode ) | 72 | if ( mColorMode ) |
73 | mText += "</font>"; | 73 | mText += "</font>"; |
74 | } | 74 | } |
75 | if (event->cancelled ()) { | 75 | if (event->cancelled ()) { |
76 | mText +="<font color=\"#B00000\">"; | 76 | mText +="<font color=\"#B00000\">"; |
77 | addTag("i",i18n("This event has been cancelled!")); | 77 | addTag("i",i18n("This event has been cancelled!")); |
78 | mText.append("<br>"); | 78 | mText.append("<br>"); |
79 | mText += "</font>"; | 79 | mText += "</font>"; |
80 | } | 80 | } |
81 | if (event->doesFloat()) { | 81 | if (event->doesFloat()) { |
82 | if (event->isMultiDay()) { | 82 | if (event->isMultiDay()) { |
83 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 83 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
84 | .arg(event->dtStartDateStr(shortDate)) | 84 | .arg(event->dtStartDateStr(shortDate)) |
85 | .arg(event->dtEndDateStr(shortDate))); | 85 | .arg(event->dtEndDateStr(shortDate))); |
86 | mText.append(i18n("<p><b>Duration:</b> %1 days</p>") | ||
87 | .arg(event->dtStart().daysTo(event->dtEnd())+1)); | ||
86 | } else { | 88 | } else { |
87 | 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 ))); |
88 | } | 90 | } |
89 | } else { | 91 | } else { |
90 | if (event->isMultiDay()) { | 92 | if (event->isMultiDay()) { |
91 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 93 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
92 | .arg(event->dtStartStr( shortDate))); | 94 | .arg(event->dtStartStr( shortDate))); |
93 | mText.append(i18n("<p><b>To:</b> %1</p>") | 95 | mText.append(i18n("<p><b>To:</b> %1</p>") |
94 | .arg(event->dtEndStr(shortDate))); | 96 | .arg(event->dtEndStr(shortDate))); |
95 | } else { | 97 | } else { |
96 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 98 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
97 | .arg(event->dtStartTimeStr()) | 99 | .arg(event->dtStartTimeStr()) |
98 | .arg(event->dtEndTimeStr())); | 100 | .arg(event->dtEndTimeStr())); |
99 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 101 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
100 | .arg(event->dtStartDateStr( shortDate ))); | 102 | .arg(event->dtStartDateStr( shortDate ))); |
101 | } | 103 | } |
102 | } | 104 | } |
103 | if (!event->location().isEmpty()) { | 105 | if (!event->location().isEmpty()) { |
104 | addTag("b",i18n("Location: ")); | 106 | addTag("b",i18n("Location: ")); |
105 | mText.append(deTag(event->location())+"<br>"); | 107 | mText.append(deTag(event->location())+"<br>"); |
106 | } | 108 | } |
107 | 109 | ||
108 | if (event->doesRecur()) { | 110 | if (event->doesRecur()) { |
109 | 111 | ||
110 | QString recurText = event->recurrence()->recurrenceText(); | 112 | QString recurText = event->recurrence()->recurrenceText(); |
111 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 113 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
112 | 114 | ||
113 | bool ok; | 115 | bool ok; |
114 | QDate start = QDate::currentDate(); | 116 | QDate start = QDate::currentDate(); |
115 | QDateTime next; | 117 | QDateTime next; |
116 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 118 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
117 | if ( ok ) { | 119 | if ( ok ) { |
118 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 120 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
119 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 121 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
120 | 122 | ||
121 | } else { | 123 | } else { |
122 | bool last; | 124 | bool last; |
123 | QDate nextd; | 125 | QDate nextd; |
124 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 126 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
125 | if ( last ) { | 127 | if ( last ) { |
126 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 128 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
127 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 129 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
128 | } | 130 | } |
129 | } | 131 | } |
130 | } | 132 | } |
131 | 133 | ||
132 | 134 | ||
133 | if (event->isAlarmEnabled()) { | 135 | if (event->isAlarmEnabled()) { |
134 | Alarm *alarm =event->alarms().first() ; | 136 | Alarm *alarm =event->alarms().first() ; |
135 | QDateTime t = alarm->time(); | 137 | QDateTime t = alarm->time(); |
136 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 138 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
137 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); | 139 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); |
138 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 140 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
139 | //addTag("p",s); | 141 | //addTag("p",s); |
140 | } | 142 | } |
141 | 143 | ||
142 | 144 | ||
143 | 145 | ||
144 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 146 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
145 | // mText.append(event->secrecyStr()+"<br>"); | 147 | // mText.append(event->secrecyStr()+"<br>"); |
146 | formatCategories(event); | 148 | formatCategories(event); |
147 | 149 | ||
148 | formatAttendees(event); | 150 | formatAttendees(event); |
149 | 151 | ||
150 | if ( mCreated ) { | 152 | if ( mCreated ) { |
151 | #ifdef DESKTOP_VERSION | 153 | #ifdef DESKTOP_VERSION |
152 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 154 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
153 | #else | 155 | #else |
154 | addTag("p",i18n("<b>Created: ") +" </b>"); | 156 | addTag("p",i18n("<b>Created: ") +" </b>"); |
155 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 157 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
156 | #endif | 158 | #endif |
157 | 159 | ||
158 | } | 160 | } |
159 | if ( mModified ) { | 161 | if ( mModified ) { |
160 | #ifdef DESKTOP_VERSION | 162 | #ifdef DESKTOP_VERSION |
161 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 163 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
162 | #else | 164 | #else |
163 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 165 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
164 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 166 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
165 | #endif | 167 | #endif |
166 | 168 | ||
167 | } | 169 | } |
168 | if ( mDetails ) { | 170 | if ( mDetails ) { |
169 | if (!event->description().isEmpty()) { | 171 | if (!event->description().isEmpty()) { |
170 | addTag("p",i18n("<b>Details: </b>")); | 172 | addTag("p",i18n("<b>Details: </b>")); |
171 | addTag("p",deTag(event->description())); | 173 | addTag("p",deTag(event->description())); |
172 | } | 174 | } |
173 | } | 175 | } |
174 | 176 | ||
175 | } | 177 | } |
176 | 178 | ||
177 | void KIncidenceFormatter::setTodo(Todo *event ) | 179 | void KIncidenceFormatter::setTodo(Todo *event ) |
178 | { | 180 | { |
179 | int mode = 0; | 181 | int mode = 0; |
180 | mCurrentIncidence = event; | 182 | mCurrentIncidence = event; |
181 | bool shortDate = true; | 183 | bool shortDate = true; |
182 | if (mode == 0 ) { | 184 | if (mode == 0 ) { |
183 | addTag("h3",deTag(event->summary())); | 185 | addTag("h3",deTag(event->summary())); |
184 | formatReadOnly(event); | 186 | formatReadOnly(event); |
185 | } | 187 | } |
186 | else { | 188 | else { |
187 | if ( mColorMode == 1 ) { | 189 | if ( mColorMode == 1 ) { |
188 | mText +="<font color=\"#00A000\">"; | 190 | mText +="<font color=\"#00A000\">"; |
189 | } | 191 | } |
190 | if ( mColorMode == 2 ) { | 192 | if ( mColorMode == 2 ) { |
191 | mText +="<font color=\"#B00000\">"; | 193 | mText +="<font color=\"#B00000\">"; |
192 | } | 194 | } |
193 | if ( mode == 1 ) { | 195 | if ( mode == 1 ) { |
194 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 196 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
195 | } else { | 197 | } else { |
196 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 198 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
197 | } | 199 | } |
198 | formatReadOnly(event); | 200 | formatReadOnly(event); |
199 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 201 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
200 | if ( mColorMode ) | 202 | if ( mColorMode ) |
201 | mText += "</font>"; | 203 | mText += "</font>"; |
202 | } | 204 | } |
203 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 205 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
204 | mText +="<font color=\"#B00000\">"; | 206 | mText +="<font color=\"#B00000\">"; |
205 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); | 207 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); |
206 | mText += "</font>"; | 208 | mText += "</font>"; |
207 | } else { | 209 | } else { |
208 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 210 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
209 | .arg(event->percentComplete())); | 211 | .arg(event->percentComplete())); |
210 | } | 212 | } |
211 | if (event->cancelled ()) { | 213 | if (event->cancelled ()) { |
212 | mText +="<font color=\"#B00000\">"; | 214 | mText +="<font color=\"#B00000\">"; |
213 | addTag("i",i18n("This todo has been cancelled!")); | 215 | addTag("i",i18n("This todo has been cancelled!")); |
214 | mText.append("<br>"); | 216 | mText.append("<br>"); |
215 | mText += "</font>"; | 217 | mText += "</font>"; |
216 | } | 218 | } |
217 | 219 | ||
218 | 220 | ||
219 | if (event->doesRecur()) { | 221 | if (event->doesRecur()) { |
220 | 222 | ||
221 | QString recurText = event->recurrence()->recurrenceText(); | 223 | QString recurText = event->recurrence()->recurrenceText(); |
222 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | 224 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); |
223 | } | 225 | } |
224 | 226 | ||
225 | if (event->hasStartDate()) { | 227 | if (event->hasStartDate()) { |
226 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); | 228 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); |
227 | } | 229 | } |
228 | 230 | ||
229 | 231 | ||
230 | if (event->hasDueDate()) { | 232 | if (event->hasDueDate()) { |
231 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); | 233 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); |
232 | } | 234 | } |
233 | 235 | ||
234 | if (!event->location().isEmpty()) { | 236 | if (!event->location().isEmpty()) { |
235 | addTag("b",i18n("Location: ")); | 237 | addTag("b",i18n("Location: ")); |
236 | mText.append(deTag(event->location())+"<br>"); | 238 | mText.append(deTag(event->location())+"<br>"); |
237 | } | 239 | } |
238 | 240 | ||
239 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 241 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
240 | .arg(QString::number(event->priority()))); | 242 | .arg(QString::number(event->priority()))); |
241 | 243 | ||
242 | if (event->isAlarmEnabled()) { | 244 | if (event->isAlarmEnabled()) { |
243 | Alarm *alarm =event->alarms().first() ; | 245 | Alarm *alarm =event->alarms().first() ; |
244 | QDateTime t = alarm->time(); | 246 | QDateTime t = alarm->time(); |
245 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 247 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
246 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 248 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
247 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 249 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
248 | //addTag("p",s); | 250 | //addTag("p",s); |
249 | } | 251 | } |
250 | 252 | ||
251 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 253 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
252 | formatCategories(event); | 254 | formatCategories(event); |
253 | 255 | ||
254 | formatAttendees(event); | 256 | formatAttendees(event); |
255 | if ( mCreated ) { | 257 | if ( mCreated ) { |
256 | #ifdef DESKTOP_VERSION | 258 | #ifdef DESKTOP_VERSION |
257 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 259 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
258 | #else | 260 | #else |
259 | addTag("p",i18n("<b>Created: ") +" </b>"); | 261 | addTag("p",i18n("<b>Created: ") +" </b>"); |
260 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 262 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
261 | #endif | 263 | #endif |
262 | 264 | ||
263 | } | 265 | } |
264 | if ( mModified ) { | 266 | if ( mModified ) { |
265 | #ifdef DESKTOP_VERSION | 267 | #ifdef DESKTOP_VERSION |
266 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 268 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
267 | #else | 269 | #else |
268 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 270 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
269 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 271 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
270 | #endif | 272 | #endif |
271 | 273 | ||
272 | } | 274 | } |
273 | if ( mDetails ) { | 275 | if ( mDetails ) { |
274 | if (!event->description().isEmpty()) { | 276 | if (!event->description().isEmpty()) { |
275 | addTag("p",i18n("<b>Details: </b>")); | 277 | addTag("p",i18n("<b>Details: </b>")); |
276 | addTag("p",deTag(event->description())); | 278 | addTag("p",deTag(event->description())); |
277 | } | 279 | } |
278 | } | 280 | } |
279 | } | 281 | } |
280 | 282 | ||
281 | void KIncidenceFormatter::setJournal(Journal* ) | 283 | void KIncidenceFormatter::setJournal(Journal* ) |
282 | { | 284 | { |
283 | 285 | ||
284 | } | 286 | } |
285 | 287 | ||
286 | void KIncidenceFormatter::formatCategories(Incidence *event) | 288 | void KIncidenceFormatter::formatCategories(Incidence *event) |
287 | { | 289 | { |
288 | if (!event->categoriesStr().isEmpty()) { | 290 | if (!event->categoriesStr().isEmpty()) { |
289 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); | 291 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); |
290 | //mText.append(event->categoriesStr()); | 292 | //mText.append(event->categoriesStr()); |
291 | } | 293 | } |
292 | } | 294 | } |
293 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 295 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) |
294 | { | 296 | { |
295 | int number=text.contains("\n"); | 297 | int number=text.contains("\n"); |
296 | QString str = "<" + tag + ">"; | 298 | QString str = "<" + tag + ">"; |
297 | QString tmpText=text; | 299 | QString tmpText=text; |
298 | QString tmpStr=str; | 300 | QString tmpStr=str; |
299 | if(number !=-1) | 301 | if(number !=-1) |
300 | { | 302 | { |
301 | if (number > 0) { | 303 | if (number > 0) { |
302 | int pos=0; | 304 | int pos=0; |
303 | QString tmp; | 305 | QString tmp; |
304 | for(int i=0;i<=number;i++) { | 306 | for(int i=0;i<=number;i++) { |
305 | pos=tmpText.find("\n"); | 307 | pos=tmpText.find("\n"); |
306 | tmp=tmpText.left(pos); | 308 | tmp=tmpText.left(pos); |
307 | tmpText=tmpText.right(tmpText.length()-pos-1); | 309 | tmpText=tmpText.right(tmpText.length()-pos-1); |
308 | tmpStr+=tmp+"<br>"; | 310 | tmpStr+=tmp+"<br>"; |
309 | } | 311 | } |
310 | } | 312 | } |
311 | else tmpStr += tmpText; | 313 | else tmpStr += tmpText; |
312 | tmpStr+="</" + tag + ">"; | 314 | tmpStr+="</" + tag + ">"; |
313 | mText.append(tmpStr); | 315 | mText.append(tmpStr); |
314 | } | 316 | } |
315 | else | 317 | else |
316 | { | 318 | { |
317 | str += text + "</" + tag + ">"; | 319 | str += text + "</" + tag + ">"; |
318 | mText.append(str); | 320 | mText.append(str); |
319 | } | 321 | } |
320 | } | 322 | } |
321 | 323 | ||
322 | void KIncidenceFormatter::formatAttendees(Incidence *event) | 324 | void KIncidenceFormatter::formatAttendees(Incidence *event) |
323 | { | 325 | { |
324 | QPtrList<Attendee> attendees = event->attendees(); | 326 | QPtrList<Attendee> attendees = event->attendees(); |
325 | if (attendees.count()) { | 327 | if (attendees.count()) { |
326 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 328 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
327 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 329 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
328 | addTag("h3",i18n("Organizer")); | 330 | addTag("h3",i18n("Organizer")); |
329 | mText.append("<ul><li>"); | 331 | mText.append("<ul><li>"); |
330 | #if 0 | 332 | #if 0 |
331 | //ndef KORG_NOKABC | 333 | //ndef KORG_NOKABC |
332 | 334 | ||
333 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 335 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
334 | KABC::Addressee::List addressList; | 336 | KABC::Addressee::List addressList; |
335 | addressList = add_book->findByEmail(event->organizer()); | 337 | addressList = add_book->findByEmail(event->organizer()); |
336 | KABC::Addressee o = addressList.first(); | 338 | KABC::Addressee o = addressList.first(); |
337 | if (!o.isEmpty() && addressList.size()<2) { | 339 | if (!o.isEmpty() && addressList.size()<2) { |
338 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 340 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
339 | mText += o.formattedName(); | 341 | mText += o.formattedName(); |
340 | mText += "</a>\n"; | 342 | mText += "</a>\n"; |
341 | } else { | 343 | } else { |
342 | mText.append(event->organizer()); | 344 | mText.append(event->organizer()); |
343 | } | 345 | } |
344 | #else | 346 | #else |
345 | mText.append(event->organizer()); | 347 | mText.append(event->organizer()); |
346 | #endif | 348 | #endif |
347 | if (iconPath) { | 349 | if (iconPath) { |
348 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 350 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
349 | mText += "<IMG src=\"" + iconPath + "\">"; | 351 | mText += "<IMG src=\"" + iconPath + "\">"; |
350 | mText += "</a>\n"; | 352 | mText += "</a>\n"; |
351 | } | 353 | } |
352 | mText.append("</li></ul>"); | 354 | mText.append("</li></ul>"); |
353 | 355 | ||
354 | addTag("h3",i18n("Attendees")); | 356 | addTag("h3",i18n("Attendees")); |
355 | Attendee *a; | 357 | Attendee *a; |
356 | mText.append("<ul>"); | 358 | mText.append("<ul>"); |
357 | for(a=attendees.first();a;a=attendees.next()) { | 359 | for(a=attendees.first();a;a=attendees.next()) { |
358 | #if 0 | 360 | #if 0 |
359 | //ndef KORG_NOKABC | 361 | //ndef KORG_NOKABC |
360 | if (a->name().isEmpty()) { | 362 | if (a->name().isEmpty()) { |
361 | addressList = add_book->findByEmail(a->email()); | 363 | addressList = add_book->findByEmail(a->email()); |
362 | KABC::Addressee o = addressList.first(); | 364 | KABC::Addressee o = addressList.first(); |
363 | if (!o.isEmpty() && addressList.size()<2) { | 365 | if (!o.isEmpty() && addressList.size()<2) { |
364 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 366 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
365 | mText += o.formattedName(); | 367 | mText += o.formattedName(); |
366 | mText += "</a>\n"; | 368 | mText += "</a>\n"; |
367 | } else { | 369 | } else { |
368 | mText += "<li>"; | 370 | mText += "<li>"; |
369 | mText.append(a->email()); | 371 | mText.append(a->email()); |
370 | mText += "\n"; | 372 | mText += "\n"; |
371 | } | 373 | } |
372 | } else { | 374 | } else { |
373 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 375 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
374 | if (!a->name().isEmpty()) mText += a->name(); | 376 | if (!a->name().isEmpty()) mText += a->name(); |
375 | else mText += a->email(); | 377 | else mText += a->email(); |
376 | mText += "</a>\n"; | 378 | mText += "</a>\n"; |
377 | } | 379 | } |
378 | #else | 380 | #else |
379 | //qDebug("nokabc "); | 381 | //qDebug("nokabc "); |
380 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 382 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
381 | if (!a->name().isEmpty()) mText += a->name(); | 383 | if (!a->name().isEmpty()) mText += a->name(); |
382 | else mText += a->email(); | 384 | else mText += a->email(); |
383 | mText += "</a>\n"; | 385 | mText += "</a>\n"; |
384 | #endif | 386 | #endif |
385 | 387 | ||
386 | if (!a->email().isEmpty()) { | 388 | if (!a->email().isEmpty()) { |
387 | if (iconPath) { | 389 | if (iconPath) { |
388 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; | 390 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; |
389 | if ( a->RSVP() ) | 391 | if ( a->RSVP() ) |
390 | mText += "<IMG src=\"" + iconPath + "\">"; | 392 | mText += "<IMG src=\"" + iconPath + "\">"; |
391 | else | 393 | else |
392 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 394 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
393 | mText += "</a>\n"; | 395 | mText += "</a>\n"; |
394 | } | 396 | } |
395 | } | 397 | } |
396 | if (a->status() != Attendee::NeedsAction ) | 398 | if (a->status() != Attendee::NeedsAction ) |
397 | mText +="[" + a->statusStr() + "] "; | 399 | mText +="[" + a->statusStr() + "] "; |
398 | if (a->role() == Attendee::Chair ) | 400 | if (a->role() == Attendee::Chair ) |
399 | mText +="(" + a->roleStr().left(1) + ".)"; | 401 | mText +="(" + a->roleStr().left(1) + ".)"; |
400 | } | 402 | } |
401 | mText.append("</li></ul>"); | 403 | mText.append("</li></ul>"); |
402 | } | 404 | } |
403 | } | 405 | } |
404 | 406 | ||
405 | void KIncidenceFormatter::formatReadOnly(Incidence *event) | 407 | void KIncidenceFormatter::formatReadOnly(Incidence *event) |
406 | { | 408 | { |
407 | if (event->isReadOnly()) { | 409 | if (event->isReadOnly()) { |
408 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 410 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
409 | } | 411 | } |
410 | } | 412 | } |
411 | QString KIncidenceFormatter::deTag(QString text) | 413 | QString KIncidenceFormatter::deTag(QString text) |
412 | { | 414 | { |
413 | #if QT_VERSION >= 0x030000 | 415 | #if QT_VERSION >= 0x030000 |
414 | text.replace( '<' , "<" ); | 416 | text.replace( '<' , "<" ); |
415 | text.replace( '>' , ">" ); | 417 | text.replace( '>' , ">" ); |
416 | #else | 418 | #else |
417 | if ( text.find ('<') >= 0 ) { | 419 | if ( text.find ('<') >= 0 ) { |
418 | text.replace( QRegExp("<") , "<" ); | 420 | text.replace( QRegExp("<") , "<" ); |
419 | } | 421 | } |
420 | if ( text.find ('>') >= 0 ) { | 422 | if ( text.find ('>') >= 0 ) { |
421 | text.replace( QRegExp(">") , ">" ); | 423 | text.replace( QRegExp(">") , ">" ); |
422 | } | 424 | } |
423 | #endif | 425 | #endif |
424 | return text; | 426 | return text; |
425 | } | 427 | } |