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