summaryrefslogtreecommitdiffabout
path: root/libkcal/kincidenceformatter.cpp
Unidiff
Diffstat (limited to 'libkcal/kincidenceformatter.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/kincidenceformatter.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 0d9c3f4..cc3088a 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -147,96 +147,108 @@ void KIncidenceFormatter::setEvent(Event *event)
147 formatReadOnly(event); 147 formatReadOnly(event);
148 formatAttendees(event); 148 formatAttendees(event);
149 149
150 150
151} 151}
152 152
153void KIncidenceFormatter::setTodo(Todo *event ) 153void KIncidenceFormatter::setTodo(Todo *event )
154{ 154{
155 int mode = 0; 155 int mode = 0;
156 mCurrentIncidence = event; 156 mCurrentIncidence = event;
157 bool shortDate = true; 157 bool shortDate = true;
158 if (mode == 0 ) 158 if (mode == 0 )
159 addTag("h3",event->summary()); 159 addTag("h3",event->summary());
160 else { 160 else {
161 if ( mColorMode == 1 ) { 161 if ( mColorMode == 1 ) {
162 mText +="<font color=\"#00A000\">"; 162 mText +="<font color=\"#00A000\">";
163 } 163 }
164 if ( mColorMode == 2 ) { 164 if ( mColorMode == 2 ) {
165 mText +="<font color=\"#B00000\">"; 165 mText +="<font color=\"#B00000\">";
166 } 166 }
167 if ( mode == 1 ) { 167 if ( mode == 1 ) {
168 addTag("h2",i18n( "Local: " ) +event->summary()); 168 addTag("h2",i18n( "Local: " ) +event->summary());
169 } else { 169 } else {
170 addTag("h2",i18n( "Remote: " ) +event->summary()); 170 addTag("h2",i18n( "Remote: " ) +event->summary());
171 } 171 }
172 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 172 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
173 if ( mColorMode ) 173 if ( mColorMode )
174 mText += "</font>"; 174 mText += "</font>";
175 } 175 }
176 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 176 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
177 mText +="<font color=\"#B00000\">"; 177 mText +="<font color=\"#B00000\">";
178 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); 178 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) );
179 mText += "</font>"; 179 mText += "</font>";
180 } else { 180 } else {
181 mText.append(i18n("<p><i>%1 % completed</i></p>") 181 mText.append(i18n("<p><i>%1 % completed</i></p>")
182 .arg(event->percentComplete())); 182 .arg(event->percentComplete()));
183 } 183 }
184 if (event->cancelled ()) { 184 if (event->cancelled ()) {
185 mText +="<font color=\"#B00000\">"; 185 mText +="<font color=\"#B00000\">";
186 addTag("i",i18n("This todo has been cancelled!")); 186 addTag("i",i18n("This todo has been cancelled!"));
187 mText.append("<br>"); 187 mText.append("<br>");
188 mText += "</font>"; 188 mText += "</font>";
189 } 189 }
190 190
191 if (!event->location().isEmpty()) { 191 if (!event->location().isEmpty()) {
192 addTag("b",i18n("Location: ")); 192 addTag("b",i18n("Location: "));
193 mText.append(event->location()+"<br>"); 193 mText.append(event->location()+"<br>");
194 } 194 }
195
196 if (event->recurrence()->doesRecur()) {
197
198 QString recurText = event->recurrence()->recurrenceText();
199 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>");
200 }
201
202 if (event->hasStartDate()) {
203 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate)));
204 }
205
206
195 if (event->hasDueDate()) { 207 if (event->hasDueDate()) {
196 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); 208 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
197 } 209 }
198 mText.append(i18n("<p><b>Priority:</b> %2</p>") 210 mText.append(i18n("<p><b>Priority:</b> %2</p>")
199 .arg(QString::number(event->priority()))); 211 .arg(QString::number(event->priority())));
200 212
201 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 213 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
202 formatCategories(event); 214 formatCategories(event);
203 if (!event->description().isEmpty()) { 215 if (!event->description().isEmpty()) {
204 addTag("p",i18n("<b>Details: </b>")); 216 addTag("p",i18n("<b>Details: </b>"));
205 addTag("p",event->description()); 217 addTag("p",event->description());
206 } 218 }
207 219
208 220
209 221
210 formatReadOnly(event); 222 formatReadOnly(event);
211 formatAttendees(event); 223 formatAttendees(event);
212 224
213} 225}
214 226
215void KIncidenceFormatter::setJournal(Journal* ) 227void KIncidenceFormatter::setJournal(Journal* )
216{ 228{
217 229
218} 230}
219 231
220void KIncidenceFormatter::formatCategories(Incidence *event) 232void KIncidenceFormatter::formatCategories(Incidence *event)
221{ 233{
222 if (!event->categoriesStr().isEmpty()) { 234 if (!event->categoriesStr().isEmpty()) {
223 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); 235 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() );
224 //mText.append(event->categoriesStr()); 236 //mText.append(event->categoriesStr());
225 } 237 }
226} 238}
227void KIncidenceFormatter::addTag(const QString & tag,const QString & text) 239void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
228{ 240{
229 int number=text.contains("\n"); 241 int number=text.contains("\n");
230 QString str = "<" + tag + ">"; 242 QString str = "<" + tag + ">";
231 QString tmpText=text; 243 QString tmpText=text;
232 QString tmpStr=str; 244 QString tmpStr=str;
233 if(number !=-1) 245 if(number !=-1)
234 { 246 {
235 if (number > 0) { 247 if (number > 0) {
236 int pos=0; 248 int pos=0;
237 QString tmp; 249 QString tmp;
238 for(int i=0;i<=number;i++) { 250 for(int i=0;i<=number;i++) {
239 pos=tmpText.find("\n"); 251 pos=tmpText.find("\n");
240 tmp=tmpText.left(pos); 252 tmp=tmpText.left(pos);
241 tmpText=tmpText.right(tmpText.length()-pos-1); 253 tmpText=tmpText.right(tmpText.length()-pos-1);
242 tmpStr+=tmp+"<br>"; 254 tmpStr+=tmp+"<br>";