author | zautrix <zautrix> | 2005-02-17 21:31:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-17 21:31:18 (UTC) |
commit | 8e8d2bd0c31eb272a7f26756252ff4930d0602bc (patch) (unidiff) | |
tree | 8392e9ca561d1444bcd949e9f1aaf78f698cde98 /libkcal | |
parent | 002e4f8cea2352e4b9a046b98f66be946fbeb5fc (diff) | |
download | kdepimpi-8e8d2bd0c31eb272a7f26756252ff4930d0602bc.zip kdepimpi-8e8d2bd0c31eb272a7f26756252ff4930d0602bc.tar.gz kdepimpi-8e8d2bd0c31eb272a7f26756252ff4930d0602bc.tar.bz2 |
fixes
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 46 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.h | 3 |
2 files changed, 36 insertions, 13 deletions
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index cc3088a..1751ae3 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -1,356 +1,378 @@ | |||
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 ) | 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; | ||
21 | mCreated = created ; | ||
22 | mModified = modified; | ||
20 | mText = ""; | 23 | mText = ""; |
21 | if ( inc->type() == "Event" ) | 24 | if ( inc->type() == "Event" ) |
22 | setEvent((Event *) inc ); | 25 | setEvent((Event *) inc ); |
23 | else if ( inc->type() == "Todo" ) | 26 | else if ( inc->type() == "Todo" ) |
24 | setTodo((Todo *) inc ); | 27 | setTodo((Todo *) inc ); |
25 | return mText; | 28 | return mText; |
26 | } | 29 | } |
27 | 30 | ||
28 | KIncidenceFormatter* KIncidenceFormatter::instance() | 31 | KIncidenceFormatter* KIncidenceFormatter::instance() |
29 | { | 32 | { |
30 | if (!mInstance) { | 33 | if (!mInstance) { |
31 | mInstance = insd.setObject(new KIncidenceFormatter()); | 34 | mInstance = insd.setObject(new KIncidenceFormatter()); |
32 | } | 35 | } |
33 | return mInstance; | 36 | return mInstance; |
34 | } | 37 | } |
35 | KIncidenceFormatter::~KIncidenceFormatter() | 38 | KIncidenceFormatter::~KIncidenceFormatter() |
36 | { | 39 | { |
37 | if (mInstance == this) | 40 | if (mInstance == this) |
38 | mInstance = insd.setObject(0); | 41 | mInstance = insd.setObject(0); |
39 | //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); | 42 | //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); |
40 | } | 43 | } |
41 | KIncidenceFormatter::KIncidenceFormatter() | 44 | KIncidenceFormatter::KIncidenceFormatter() |
42 | { | 45 | { |
43 | mColorMode = 0; | 46 | mColorMode = 0; |
44 | } | 47 | } |
45 | void KIncidenceFormatter::setEvent(Event *event) | 48 | void KIncidenceFormatter::setEvent(Event *event) |
46 | { | 49 | { |
47 | int mode = 0; | 50 | int mode = 0; |
48 | mCurrentIncidence = event; | 51 | mCurrentIncidence = event; |
49 | bool shortDate = true; | 52 | bool shortDate = true; |
50 | if ( mode == 0 ) { | 53 | if ( mode == 0 ) { |
51 | addTag("h3",event->summary()); | 54 | addTag("h3",event->summary()); |
52 | } | 55 | } |
53 | else { | 56 | else { |
54 | if ( mColorMode == 1 ) { | 57 | if ( mColorMode == 1 ) { |
55 | mText +="<font color=\"#00A000\">"; | 58 | mText +="<font color=\"#00A000\">"; |
56 | } | 59 | } |
57 | if ( mColorMode == 2 ) { | 60 | if ( mColorMode == 2 ) { |
58 | mText +="<font color=\"#C00000\">"; | 61 | mText +="<font color=\"#C00000\">"; |
59 | } | 62 | } |
60 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 63 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
61 | if ( mode == 1 ) { | 64 | if ( mode == 1 ) { |
62 | addTag("h2",i18n( "Local: " ) +event->summary()); | 65 | addTag("h2",i18n( "Local: " ) +event->summary()); |
63 | } else { | 66 | } else { |
64 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 67 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
65 | } | 68 | } |
66 | 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 ) ); |
67 | if ( mColorMode ) | 70 | if ( mColorMode ) |
68 | mText += "</font>"; | 71 | mText += "</font>"; |
69 | } | 72 | } |
70 | if (event->cancelled ()) { | 73 | if (event->cancelled ()) { |
71 | mText +="<font color=\"#B00000\">"; | 74 | mText +="<font color=\"#B00000\">"; |
72 | addTag("i",i18n("This event has been cancelled!")); | 75 | addTag("i",i18n("This event has been cancelled!")); |
73 | mText.append("<br>"); | 76 | mText.append("<br>"); |
74 | mText += "</font>"; | 77 | mText += "</font>"; |
75 | } | 78 | } |
76 | if (!event->location().isEmpty()) { | 79 | if (!event->location().isEmpty()) { |
77 | addTag("b",i18n("Location: ")); | 80 | addTag("b",i18n("Location: ")); |
78 | mText.append(event->location()+"<br>"); | 81 | mText.append(event->location()+"<br>"); |
79 | } | 82 | } |
80 | if (event->doesFloat()) { | 83 | if (event->doesFloat()) { |
81 | if (event->isMultiDay()) { | 84 | if (event->isMultiDay()) { |
82 | 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>") |
83 | .arg(event->dtStartDateStr(shortDate)) | 86 | .arg(event->dtStartDateStr(shortDate)) |
84 | .arg(event->dtEndDateStr(shortDate))); | 87 | .arg(event->dtEndDateStr(shortDate))); |
85 | } else { | 88 | } else { |
86 | 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 ))); |
87 | } | 90 | } |
88 | } else { | 91 | } else { |
89 | if (event->isMultiDay()) { | 92 | if (event->isMultiDay()) { |
90 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 93 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
91 | .arg(event->dtStartStr( shortDate))); | 94 | .arg(event->dtStartStr( shortDate))); |
92 | mText.append(i18n("<p><b>To:</b> %1</p>") | 95 | mText.append(i18n("<p><b>To:</b> %1</p>") |
93 | .arg(event->dtEndStr(shortDate))); | 96 | .arg(event->dtEndStr(shortDate))); |
94 | } else { | 97 | } else { |
95 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 98 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
96 | .arg(event->dtStartDateStr( shortDate ))); | 99 | .arg(event->dtStartDateStr( shortDate ))); |
97 | 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>") |
98 | .arg(event->dtStartTimeStr()) | 101 | .arg(event->dtStartTimeStr()) |
99 | .arg(event->dtEndTimeStr())); | 102 | .arg(event->dtEndTimeStr())); |
100 | } | 103 | } |
101 | } | 104 | } |
102 | 105 | ||
103 | if (event->recurrence()->doesRecur()) { | 106 | if (event->recurrence()->doesRecur()) { |
104 | 107 | ||
105 | QString recurText = event->recurrence()->recurrenceText(); | 108 | QString recurText = event->recurrence()->recurrenceText(); |
106 | 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>"); |
107 | 110 | ||
108 | bool ok; | 111 | bool ok; |
109 | QDate start = QDate::currentDate(); | 112 | QDate start = QDate::currentDate(); |
110 | QDateTime next; | 113 | QDateTime next; |
111 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 114 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
112 | if ( ok ) { | 115 | if ( ok ) { |
113 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 116 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
114 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 117 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
115 | 118 | ||
116 | } else { | 119 | } else { |
117 | bool last; | 120 | bool last; |
118 | QDate nextd; | 121 | QDate nextd; |
119 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 122 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
120 | if ( last ) { | 123 | if ( last ) { |
121 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 124 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
122 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 125 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
123 | } | 126 | } |
124 | } | 127 | } |
125 | } | 128 | } |
126 | 129 | ||
127 | 130 | ||
128 | if (event->isAlarmEnabled()) { | 131 | if (event->isAlarmEnabled()) { |
129 | Alarm *alarm =event->alarms().first() ; | 132 | Alarm *alarm =event->alarms().first() ; |
130 | QDateTime t = alarm->time(); | 133 | QDateTime t = alarm->time(); |
131 | int min = t.secsTo( event->dtStart() )/60; | 134 | int min = t.secsTo( event->dtStart() )/60; |
132 | QString s =i18n("(%1 min before)").arg( min ); | 135 | QString s =i18n("(%1 min before)").arg( min ); |
133 | 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 )); |
134 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 137 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
135 | //addTag("p",s); | 138 | //addTag("p",s); |
136 | } | 139 | } |
137 | 140 | ||
138 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 141 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
139 | // mText.append(event->secrecyStr()+"<br>"); | 142 | // mText.append(event->secrecyStr()+"<br>"); |
140 | formatCategories(event); | 143 | formatCategories(event); |
141 | if (!event->description().isEmpty()) { | 144 | if ( mDetails ) { |
142 | addTag("p",i18n("<b>Details: </b>")); | 145 | if (!event->description().isEmpty()) { |
143 | addTag("p",event->description()); | 146 | addTag("p",i18n("<b>Details: </b>")); |
147 | addTag("p",event->description()); | ||
148 | } | ||
144 | } | 149 | } |
145 | 150 | ||
146 | |||
147 | formatReadOnly(event); | 151 | formatReadOnly(event); |
148 | formatAttendees(event); | 152 | formatAttendees(event); |
149 | 153 | ||
154 | if ( mCreated ) { | ||
155 | addTag("p",i18n("<b>Created: ") +" </b>"); | ||
156 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | ||
157 | |||
158 | } | ||
159 | if ( mModified ) { | ||
160 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | ||
161 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | ||
162 | |||
163 | } | ||
150 | 164 | ||
151 | } | 165 | } |
152 | 166 | ||
153 | void KIncidenceFormatter::setTodo(Todo *event ) | 167 | void KIncidenceFormatter::setTodo(Todo *event ) |
154 | { | 168 | { |
155 | int mode = 0; | 169 | int mode = 0; |
156 | mCurrentIncidence = event; | 170 | mCurrentIncidence = event; |
157 | bool shortDate = true; | 171 | bool shortDate = true; |
158 | if (mode == 0 ) | 172 | if (mode == 0 ) |
159 | addTag("h3",event->summary()); | 173 | addTag("h3",event->summary()); |
160 | else { | 174 | else { |
161 | if ( mColorMode == 1 ) { | 175 | if ( mColorMode == 1 ) { |
162 | mText +="<font color=\"#00A000\">"; | 176 | mText +="<font color=\"#00A000\">"; |
163 | } | 177 | } |
164 | if ( mColorMode == 2 ) { | 178 | if ( mColorMode == 2 ) { |
165 | mText +="<font color=\"#B00000\">"; | 179 | mText +="<font color=\"#B00000\">"; |
166 | } | 180 | } |
167 | if ( mode == 1 ) { | 181 | if ( mode == 1 ) { |
168 | addTag("h2",i18n( "Local: " ) +event->summary()); | 182 | addTag("h2",i18n( "Local: " ) +event->summary()); |
169 | } else { | 183 | } else { |
170 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 184 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
171 | } | 185 | } |
172 | 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 ) ); |
173 | if ( mColorMode ) | 187 | if ( mColorMode ) |
174 | mText += "</font>"; | 188 | mText += "</font>"; |
175 | } | 189 | } |
176 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 190 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
177 | mText +="<font color=\"#B00000\">"; | 191 | mText +="<font color=\"#B00000\">"; |
178 | 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) ) ); |
179 | mText += "</font>"; | 193 | mText += "</font>"; |
180 | } else { | 194 | } else { |
181 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 195 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
182 | .arg(event->percentComplete())); | 196 | .arg(event->percentComplete())); |
183 | } | 197 | } |
184 | if (event->cancelled ()) { | 198 | if (event->cancelled ()) { |
185 | mText +="<font color=\"#B00000\">"; | 199 | mText +="<font color=\"#B00000\">"; |
186 | addTag("i",i18n("This todo has been cancelled!")); | 200 | addTag("i",i18n("This todo has been cancelled!")); |
187 | mText.append("<br>"); | 201 | mText.append("<br>"); |
188 | mText += "</font>"; | 202 | mText += "</font>"; |
189 | } | 203 | } |
190 | 204 | ||
191 | if (!event->location().isEmpty()) { | 205 | if (!event->location().isEmpty()) { |
192 | addTag("b",i18n("Location: ")); | 206 | addTag("b",i18n("Location: ")); |
193 | mText.append(event->location()+"<br>"); | 207 | mText.append(event->location()+"<br>"); |
194 | } | 208 | } |
195 | 209 | ||
196 | if (event->recurrence()->doesRecur()) { | 210 | if (event->recurrence()->doesRecur()) { |
197 | 211 | ||
198 | QString recurText = event->recurrence()->recurrenceText(); | 212 | QString recurText = event->recurrence()->recurrenceText(); |
199 | 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>"); |
200 | } | 214 | } |
201 | 215 | ||
202 | if (event->hasStartDate()) { | 216 | if (event->hasStartDate()) { |
203 | 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))); |
204 | } | 218 | } |
205 | 219 | ||
206 | 220 | ||
207 | if (event->hasDueDate()) { | 221 | if (event->hasDueDate()) { |
208 | 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))); |
209 | } | 223 | } |
210 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 224 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
211 | .arg(QString::number(event->priority()))); | 225 | .arg(QString::number(event->priority()))); |
212 | 226 | ||
213 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 227 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
214 | formatCategories(event); | 228 | formatCategories(event); |
215 | if (!event->description().isEmpty()) { | 229 | if ( mDetails ) { |
216 | addTag("p",i18n("<b>Details: </b>")); | 230 | if (!event->description().isEmpty()) { |
217 | addTag("p",event->description()); | 231 | addTag("p",i18n("<b>Details: </b>")); |
232 | addTag("p",event->description()); | ||
233 | } | ||
218 | } | 234 | } |
219 | |||
220 | |||
221 | |||
222 | formatReadOnly(event); | 235 | formatReadOnly(event); |
223 | formatAttendees(event); | 236 | formatAttendees(event); |
224 | 237 | if ( mCreated ) { | |
238 | addTag("p",i18n("<b>Created: ") +" </b>"); | ||
239 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | ||
240 | |||
241 | } | ||
242 | if ( mModified ) { | ||
243 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | ||
244 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | ||
245 | |||
246 | } | ||
225 | } | 247 | } |
226 | 248 | ||
227 | void KIncidenceFormatter::setJournal(Journal* ) | 249 | void KIncidenceFormatter::setJournal(Journal* ) |
228 | { | 250 | { |
229 | 251 | ||
230 | } | 252 | } |
231 | 253 | ||
232 | void KIncidenceFormatter::formatCategories(Incidence *event) | 254 | void KIncidenceFormatter::formatCategories(Incidence *event) |
233 | { | 255 | { |
234 | if (!event->categoriesStr().isEmpty()) { | 256 | if (!event->categoriesStr().isEmpty()) { |
235 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); | 257 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); |
236 | //mText.append(event->categoriesStr()); | 258 | //mText.append(event->categoriesStr()); |
237 | } | 259 | } |
238 | } | 260 | } |
239 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 261 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) |
240 | { | 262 | { |
241 | int number=text.contains("\n"); | 263 | int number=text.contains("\n"); |
242 | QString str = "<" + tag + ">"; | 264 | QString str = "<" + tag + ">"; |
243 | QString tmpText=text; | 265 | QString tmpText=text; |
244 | QString tmpStr=str; | 266 | QString tmpStr=str; |
245 | if(number !=-1) | 267 | if(number !=-1) |
246 | { | 268 | { |
247 | if (number > 0) { | 269 | if (number > 0) { |
248 | int pos=0; | 270 | int pos=0; |
249 | QString tmp; | 271 | QString tmp; |
250 | for(int i=0;i<=number;i++) { | 272 | for(int i=0;i<=number;i++) { |
251 | pos=tmpText.find("\n"); | 273 | pos=tmpText.find("\n"); |
252 | tmp=tmpText.left(pos); | 274 | tmp=tmpText.left(pos); |
253 | tmpText=tmpText.right(tmpText.length()-pos-1); | 275 | tmpText=tmpText.right(tmpText.length()-pos-1); |
254 | tmpStr+=tmp+"<br>"; | 276 | tmpStr+=tmp+"<br>"; |
255 | } | 277 | } |
256 | } | 278 | } |
257 | else tmpStr += tmpText; | 279 | else tmpStr += tmpText; |
258 | tmpStr+="</" + tag + ">"; | 280 | tmpStr+="</" + tag + ">"; |
259 | mText.append(tmpStr); | 281 | mText.append(tmpStr); |
260 | } | 282 | } |
261 | else | 283 | else |
262 | { | 284 | { |
263 | str += text + "</" + tag + ">"; | 285 | str += text + "</" + tag + ">"; |
264 | mText.append(str); | 286 | mText.append(str); |
265 | } | 287 | } |
266 | } | 288 | } |
267 | 289 | ||
268 | void KIncidenceFormatter::formatAttendees(Incidence *event) | 290 | void KIncidenceFormatter::formatAttendees(Incidence *event) |
269 | { | 291 | { |
270 | QPtrList<Attendee> attendees = event->attendees(); | 292 | QPtrList<Attendee> attendees = event->attendees(); |
271 | if (attendees.count()) { | 293 | if (attendees.count()) { |
272 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 294 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
273 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 295 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
274 | addTag("h3",i18n("Organizer")); | 296 | addTag("h3",i18n("Organizer")); |
275 | mText.append("<ul><li>"); | 297 | mText.append("<ul><li>"); |
276 | #if 0 | 298 | #if 0 |
277 | //ndef KORG_NOKABC | 299 | //ndef KORG_NOKABC |
278 | 300 | ||
279 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 301 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
280 | KABC::Addressee::List addressList; | 302 | KABC::Addressee::List addressList; |
281 | addressList = add_book->findByEmail(event->organizer()); | 303 | addressList = add_book->findByEmail(event->organizer()); |
282 | KABC::Addressee o = addressList.first(); | 304 | KABC::Addressee o = addressList.first(); |
283 | if (!o.isEmpty() && addressList.size()<2) { | 305 | if (!o.isEmpty() && addressList.size()<2) { |
284 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 306 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
285 | mText += o.formattedName(); | 307 | mText += o.formattedName(); |
286 | mText += "</a>\n"; | 308 | mText += "</a>\n"; |
287 | } else { | 309 | } else { |
288 | mText.append(event->organizer()); | 310 | mText.append(event->organizer()); |
289 | } | 311 | } |
290 | #else | 312 | #else |
291 | mText.append(event->organizer()); | 313 | mText.append(event->organizer()); |
292 | #endif | 314 | #endif |
293 | if (iconPath) { | 315 | if (iconPath) { |
294 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 316 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
295 | mText += "<IMG src=\"" + iconPath + "\">"; | 317 | mText += "<IMG src=\"" + iconPath + "\">"; |
296 | mText += "</a>\n"; | 318 | mText += "</a>\n"; |
297 | } | 319 | } |
298 | mText.append("</li></ul>"); | 320 | mText.append("</li></ul>"); |
299 | 321 | ||
300 | addTag("h3",i18n("Attendees")); | 322 | addTag("h3",i18n("Attendees")); |
301 | Attendee *a; | 323 | Attendee *a; |
302 | mText.append("<ul>"); | 324 | mText.append("<ul>"); |
303 | for(a=attendees.first();a;a=attendees.next()) { | 325 | for(a=attendees.first();a;a=attendees.next()) { |
304 | #if 0 | 326 | #if 0 |
305 | //ndef KORG_NOKABC | 327 | //ndef KORG_NOKABC |
306 | if (a->name().isEmpty()) { | 328 | if (a->name().isEmpty()) { |
307 | addressList = add_book->findByEmail(a->email()); | 329 | addressList = add_book->findByEmail(a->email()); |
308 | KABC::Addressee o = addressList.first(); | 330 | KABC::Addressee o = addressList.first(); |
309 | if (!o.isEmpty() && addressList.size()<2) { | 331 | if (!o.isEmpty() && addressList.size()<2) { |
310 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 332 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
311 | mText += o.formattedName(); | 333 | mText += o.formattedName(); |
312 | mText += "</a>\n"; | 334 | mText += "</a>\n"; |
313 | } else { | 335 | } else { |
314 | mText += "<li>"; | 336 | mText += "<li>"; |
315 | mText.append(a->email()); | 337 | mText.append(a->email()); |
316 | mText += "\n"; | 338 | mText += "\n"; |
317 | } | 339 | } |
318 | } else { | 340 | } else { |
319 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 341 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
320 | if (!a->name().isEmpty()) mText += a->name(); | 342 | if (!a->name().isEmpty()) mText += a->name(); |
321 | else mText += a->email(); | 343 | else mText += a->email(); |
322 | mText += "</a>\n"; | 344 | mText += "</a>\n"; |
323 | } | 345 | } |
324 | #else | 346 | #else |
325 | //qDebug("nokabc "); | 347 | //qDebug("nokabc "); |
326 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 348 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
327 | if (!a->name().isEmpty()) mText += a->name(); | 349 | if (!a->name().isEmpty()) mText += a->name(); |
328 | else mText += a->email(); | 350 | else mText += a->email(); |
329 | mText += "</a>\n"; | 351 | mText += "</a>\n"; |
330 | #endif | 352 | #endif |
331 | 353 | ||
332 | if (!a->email().isEmpty()) { | 354 | if (!a->email().isEmpty()) { |
333 | if (iconPath) { | 355 | if (iconPath) { |
334 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; | 356 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; |
335 | if ( a->RSVP() ) | 357 | if ( a->RSVP() ) |
336 | mText += "<IMG src=\"" + iconPath + "\">"; | 358 | mText += "<IMG src=\"" + iconPath + "\">"; |
337 | else | 359 | else |
338 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 360 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
339 | mText += "</a>\n"; | 361 | mText += "</a>\n"; |
340 | } | 362 | } |
341 | } | 363 | } |
342 | if (a->status() != Attendee::NeedsAction ) | 364 | if (a->status() != Attendee::NeedsAction ) |
343 | mText +="[" + a->statusStr() + "] "; | 365 | mText +="[" + a->statusStr() + "] "; |
344 | if (a->role() == Attendee::Chair ) | 366 | if (a->role() == Attendee::Chair ) |
345 | mText +="(" + a->roleStr().left(1) + ".)"; | 367 | mText +="(" + a->roleStr().left(1) + ".)"; |
346 | } | 368 | } |
347 | mText.append("</li></ul>"); | 369 | mText.append("</li></ul>"); |
348 | } | 370 | } |
349 | } | 371 | } |
350 | 372 | ||
351 | void KIncidenceFormatter::formatReadOnly(Incidence *event) | 373 | void KIncidenceFormatter::formatReadOnly(Incidence *event) |
352 | { | 374 | { |
353 | if (event->isReadOnly()) { | 375 | if (event->isReadOnly()) { |
354 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 376 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
355 | } | 377 | } |
356 | } | 378 | } |
diff --git a/libkcal/kincidenceformatter.h b/libkcal/kincidenceformatter.h index 6165a9f..068e6d2 100644 --- a/libkcal/kincidenceformatter.h +++ b/libkcal/kincidenceformatter.h | |||
@@ -1,42 +1,43 @@ | |||
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 ); | 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 | bool mSyncMode; | 35 | bool mSyncMode; |
36 | bool mDetails, mCreated ,mModified; | ||
36 | 37 | ||
37 | QString mText; | 38 | QString mText; |
38 | Incidence* mCurrentIncidence; | 39 | Incidence* mCurrentIncidence; |
39 | static KIncidenceFormatter* mInstance; | 40 | static KIncidenceFormatter* mInstance; |
40 | }; | 41 | }; |
41 | 42 | ||
42 | #endif | 43 | #endif |