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