summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-10-10 01:15:44 (UTC)
committer zautrix <zautrix>2005-10-10 01:15:44 (UTC)
commita36b62685510933d1fd57d2c53d50b7f2fe2fc1c (patch) (unidiff)
treee97e078210104bdc70b9ed9d63f66e083cd0b032
parentb4ed5a3409d8a6d2f443e78306abbaf6963f0f9e (diff)
downloadkdepimpi-a36b62685510933d1fd57d2c53d50b7f2fe2fc1c.zip
kdepimpi-a36b62685510933d1fd57d2c53d50b7f2fe2fc1c.tar.gz
kdepimpi-a36b62685510933d1fd57d2c53d50b7f2fe2fc1c.tar.bz2
kkk
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/kincidenceformatter.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index f8f40f1..4dfe16a 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -1,181 +1,183 @@
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
10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; 10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
11static KStaticDeleter<KIncidenceFormatter> insd; 11static KStaticDeleter<KIncidenceFormatter> insd;
12 12
13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) 13QString 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
31KIncidenceFormatter* KIncidenceFormatter::instance() 31KIncidenceFormatter* 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}
38KIncidenceFormatter::~KIncidenceFormatter() 38KIncidenceFormatter::~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}
44KIncidenceFormatter::KIncidenceFormatter() 44KIncidenceFormatter::KIncidenceFormatter()
45{ 45{
46 mColorMode = 0; 46 mColorMode = 0;
47} 47}
48void KIncidenceFormatter::setEvent(Event *event) 48void KIncidenceFormatter::setEvent(Event *event)
49{ 49{
50 int mode = 0; 50 int mode = 0;
51 mCurrentIncidence = event; 51 mCurrentIncidence = event;
52 bool shortDate = true; 52 bool shortDate = true;
53 if ( mode == 0 ) { 53 if ( mode == 0 ) {
54 addTag("h3",deTag(event->summary())); 54 addTag("h3",deTag(event->summary()));
55 formatReadOnly(event); 55 formatReadOnly(event);
56 } 56 }
57 else { 57 else {
58 if ( mColorMode == 1 ) { 58 if ( mColorMode == 1 ) {
59 mText +="<font color=\"#00A000\">"; 59 mText +="<font color=\"#00A000\">";
60 } 60 }
61 if ( mColorMode == 2 ) { 61 if ( mColorMode == 2 ) {
62 mText +="<font color=\"#C00000\">"; 62 mText +="<font color=\"#C00000\">";
63 } 63 }
64 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 64 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
65 if ( mode == 1 ) { 65 if ( mode == 1 ) {
66 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 66 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
67 } else { 67 } else {
68 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 68 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
69 } 69 }
70 formatReadOnly(event); 70 formatReadOnly(event);
71 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 71 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
72 if ( mColorMode ) 72 if ( mColorMode )
73 mText += "</font>"; 73 mText += "</font>";
74 } 74 }
75 if (event->cancelled ()) { 75 if (event->cancelled ()) {
76 mText +="<font color=\"#B00000\">"; 76 mText +="<font color=\"#B00000\">";
77 addTag("i",i18n("This event has been cancelled!")); 77 addTag("i",i18n("This event has been cancelled!"));
78 mText.append("<br>"); 78 mText.append("<br>");
79 mText += "</font>"; 79 mText += "</font>";
80 } 80 }
81 if (event->doesFloat()) { 81 if (event->doesFloat()) {
82 if (event->isMultiDay()) { 82 if (event->isMultiDay()) {
83 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 83 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
84 .arg(event->dtStartDateStr(shortDate)) 84 .arg(event->dtStartDateStr(shortDate))
85 .arg(event->dtEndDateStr(shortDate))); 85 .arg(event->dtEndDateStr(shortDate)));
86 mText.append(i18n("<p><b>Duration:</b> %1 days</p>")
87 .arg(event->dtStart().daysTo(event->dtEnd())+1));
86 } else { 88 } else {
87 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 89 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
88 } 90 }
89 } else { 91 } else {
90 if (event->isMultiDay()) { 92 if (event->isMultiDay()) {
91 mText.append(i18n("<p><b>From:</b> %1</p> ") 93 mText.append(i18n("<p><b>From:</b> %1</p> ")
92 .arg(event->dtStartStr( shortDate))); 94 .arg(event->dtStartStr( shortDate)));
93 mText.append(i18n("<p><b>To:</b> %1</p>") 95 mText.append(i18n("<p><b>To:</b> %1</p>")
94 .arg(event->dtEndStr(shortDate))); 96 .arg(event->dtEndStr(shortDate)));
95 } else { 97 } else {
96 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 98 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
97 .arg(event->dtStartTimeStr()) 99 .arg(event->dtStartTimeStr())
98 .arg(event->dtEndTimeStr())); 100 .arg(event->dtEndTimeStr()));
99 mText.append(i18n("<p><b>On:</b> %1</p> ") 101 mText.append(i18n("<p><b>On:</b> %1</p> ")
100 .arg(event->dtStartDateStr( shortDate ))); 102 .arg(event->dtStartDateStr( shortDate )));
101 } 103 }
102 } 104 }
103 if (!event->location().isEmpty()) { 105 if (!event->location().isEmpty()) {
104 addTag("b",i18n("Location: ")); 106 addTag("b",i18n("Location: "));
105 mText.append(deTag(event->location())+"<br>"); 107 mText.append(deTag(event->location())+"<br>");
106 } 108 }
107 109
108 if (event->doesRecur()) { 110 if (event->doesRecur()) {
109 111
110 QString recurText = event->recurrence()->recurrenceText(); 112 QString recurText = event->recurrence()->recurrenceText();
111 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 113 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
112 114
113 bool ok; 115 bool ok;
114 QDate start = QDate::currentDate(); 116 QDate start = QDate::currentDate();
115 QDateTime next; 117 QDateTime next;
116 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 118 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
117 if ( ok ) { 119 if ( ok ) {
118 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 120 addTag("p",i18n("<b>Next recurrence is on:</b>") );
119 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 121 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
120 122
121 } else { 123 } else {
122 bool last; 124 bool last;
123 QDate nextd; 125 QDate nextd;
124 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 126 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
125 if ( last ) { 127 if ( last ) {
126 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 128 addTag("p",i18n("<b>Last recurrence was on:</b>") );
127 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 129 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
128 } 130 }
129 } 131 }
130 } 132 }
131 133
132 134
133 if (event->isAlarmEnabled()) { 135 if (event->isAlarmEnabled()) {
134 Alarm *alarm =event->alarms().first() ; 136 Alarm *alarm =event->alarms().first() ;
135 QDateTime t = alarm->time(); 137 QDateTime t = alarm->time();
136 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 138 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
137 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); 139 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
138 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 140 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
139 //addTag("p",s); 141 //addTag("p",s);
140 } 142 }
141 143
142 144
143 145
144 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 146 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
145 // mText.append(event->secrecyStr()+"<br>"); 147 // mText.append(event->secrecyStr()+"<br>");
146 formatCategories(event); 148 formatCategories(event);
147 149
148 formatAttendees(event); 150 formatAttendees(event);
149 151
150 if ( mCreated ) { 152 if ( mCreated ) {
151#ifdef DESKTOP_VERSION 153#ifdef DESKTOP_VERSION
152 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 154 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
153#else 155#else
154 addTag("p",i18n("<b>Created: ") +" </b>"); 156 addTag("p",i18n("<b>Created: ") +" </b>");
155 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 157 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
156#endif 158#endif
157 159
158 } 160 }
159 if ( mModified ) { 161 if ( mModified ) {
160#ifdef DESKTOP_VERSION 162#ifdef DESKTOP_VERSION
161 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 163 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
162#else 164#else
163 addTag("p",i18n("<b>Last modified: ") +" </b>"); 165 addTag("p",i18n("<b>Last modified: ") +" </b>");
164 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 166 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
165#endif 167#endif
166 168
167 } 169 }
168 if ( mDetails ) { 170 if ( mDetails ) {
169 if (!event->description().isEmpty()) { 171 if (!event->description().isEmpty()) {
170 addTag("p",i18n("<b>Details: </b>")); 172 addTag("p",i18n("<b>Details: </b>"));
171 addTag("p",deTag(event->description())); 173 addTag("p",deTag(event->description()));
172 } 174 }
173 } 175 }
174 176
175} 177}
176 178
177void KIncidenceFormatter::setTodo(Todo *event ) 179void KIncidenceFormatter::setTodo(Todo *event )
178{ 180{
179 int mode = 0; 181 int mode = 0;
180 mCurrentIncidence = event; 182 mCurrentIncidence = event;
181 bool shortDate = true; 183 bool shortDate = true;