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