-rw-r--r-- | libkcal/phoneformat.cpp | 8 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 94744fb..bc1b863 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -65,210 +65,212 @@ public: | |||
65 | todo->setID( mProfileName,QString::number( id ) ); | 65 | todo->setID( mProfileName,QString::number( id ) ); |
66 | todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 66 | todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
67 | int priority; | 67 | int priority; |
68 | switch (ToDo->Priority) { | 68 | switch (ToDo->Priority) { |
69 | case GSM_Priority_Low : priority = 1; break; | 69 | case GSM_Priority_Low : priority = 1; break; |
70 | case GSM_Priority_Medium : priority = 3; break; | 70 | case GSM_Priority_Medium : priority = 3; break; |
71 | case GSM_Priority_High : priority = 5; break; | 71 | case GSM_Priority_High : priority = 5; break; |
72 | default :priority = 3 ;break; | 72 | default :priority = 3 ;break; |
73 | } | 73 | } |
74 | todo->setPriority( priority ); | 74 | todo->setPriority( priority ); |
75 | GSM_Phone_Functions*Phone; | 75 | GSM_Phone_Functions*Phone; |
76 | Phone=s->Phone.Functions; | 76 | Phone=s->Phone.Functions; |
77 | int j; | 77 | int j; |
78 | GSM_DateTime* dtp; | 78 | GSM_DateTime* dtp; |
79 | bool alarm = false; | 79 | bool alarm = false; |
80 | QDateTime alarmDt; | 80 | QDateTime alarmDt; |
81 | GSM_Category Category; | 81 | GSM_Category Category; |
82 | int error; | 82 | int error; |
83 | QString completedString = "no"; | 83 | QString completedString = "no"; |
84 | for (j=0;j<ToDo->EntriesNum;j++) { | 84 | for (j=0;j<ToDo->EntriesNum;j++) { |
85 | 85 | ||
86 | //qDebug(" for todo %d",ToDo->Location ); | 86 | //qDebug(" for todo %d",ToDo->Location ); |
87 | switch (ToDo->Entries[j].EntryType) { | 87 | switch (ToDo->Entries[j].EntryType) { |
88 | case TODO_END_DATETIME: | 88 | case TODO_END_DATETIME: |
89 | dtp = &ToDo->Entries[j].Date ; | 89 | dtp = &ToDo->Entries[j].Date ; |
90 | todo->setDtDue (fromGSM ( dtp )); | 90 | todo->setDtDue (fromGSM ( dtp )); |
91 | break; | 91 | break; |
92 | case TODO_COMPLETED: | 92 | case TODO_COMPLETED: |
93 | if ( ToDo->Entries[j].Number == 1 ) { | 93 | if ( ToDo->Entries[j].Number == 1 ) { |
94 | todo->setCompleted( true ); | 94 | todo->setCompleted( true ); |
95 | completedString = "yes"; | 95 | completedString = "yes"; |
96 | } | 96 | } |
97 | else { | 97 | else { |
98 | todo->setCompleted( false ); | 98 | todo->setCompleted( false ); |
99 | } | 99 | } |
100 | break; | 100 | break; |
101 | case TODO_ALARM_DATETIME: | 101 | case TODO_ALARM_DATETIME: |
102 | dtp = &ToDo->Entries[j].Date ; | 102 | dtp = &ToDo->Entries[j].Date ; |
103 | alarm = true; | 103 | alarm = true; |
104 | alarmDt = fromGSM ( dtp ); | 104 | alarmDt = fromGSM ( dtp ); |
105 | break; | 105 | break; |
106 | case TODO_SILENT_ALARM_DATETIME: | 106 | case TODO_SILENT_ALARM_DATETIME: |
107 | dtp = &ToDo->Entries[j].Date ; | 107 | dtp = &ToDo->Entries[j].Date ; |
108 | alarm = true; | 108 | alarm = true; |
109 | alarmDt = fromGSM ( dtp ); | 109 | alarmDt = fromGSM ( dtp ); |
110 | break; | 110 | break; |
111 | case TODO_TEXT: | 111 | case TODO_TEXT: |
112 | //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); | 112 | //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); |
113 | todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); | 113 | todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); |
114 | break; | 114 | break; |
115 | case TODO_PRIVATE: | 115 | case TODO_PRIVATE: |
116 | if ( ToDo->Entries[j].Number == 1 ) | 116 | if ( ToDo->Entries[j].Number == 1 ) |
117 | todo->setSecrecy( Incidence::SecrecyPrivate ); | 117 | todo->setSecrecy( Incidence::SecrecyPrivate ); |
118 | else | 118 | else |
119 | todo->setSecrecy( Incidence::SecrecyPublic ); | 119 | todo->setSecrecy( Incidence::SecrecyPublic ); |
120 | break; | 120 | break; |
121 | case TODO_CATEGORY: | 121 | case TODO_CATEGORY: |
122 | Category.Location = ToDo->Entries[j].Number; | 122 | Category.Location = ToDo->Entries[j].Number; |
123 | Category.Type = Category_ToDo; | 123 | Category.Type = Category_ToDo; |
124 | error=Phone->GetCategory(s, &Category); | 124 | error=Phone->GetCategory(s, &Category); |
125 | if (error == ERR_NONE) { | 125 | if (error == ERR_NONE) { |
126 | QStringList cat = todo->categories(); | 126 | QStringList cat = todo->categories(); |
127 | QString nCat = QString ( (const char*)Category.Name ); | 127 | QString nCat = QString ( (const char*)Category.Name ); |
128 | if ( !nCat.isEmpty() ) | 128 | if ( !nCat.isEmpty() ) |
129 | if ( !cat.contains( nCat )) { | 129 | if ( !cat.contains( nCat )) { |
130 | cat << nCat; | 130 | cat << nCat; |
131 | todo->setCategories( cat ); | 131 | todo->setCategories( cat ); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | break; | 134 | break; |
135 | case TODO_CONTACTID: | 135 | case TODO_CONTACTID: |
136 | #if 0 | 136 | #if 0 |
137 | // not supported | 137 | // not supported |
138 | entry.Location = ToDo->Entries[j].Number; | 138 | entry.Location = ToDo->Entries[j].Number; |
139 | entry.MemoryType = MEM_ME; | 139 | entry.MemoryType = MEM_ME; |
140 | error=Phone->GetMemory(s, &entry); | 140 | error=Phone->GetMemory(s, &entry); |
141 | if (error == ERR_NONE) { | 141 | if (error == ERR_NONE) { |
142 | name = GSM_PhonebookGetEntryName(&entry); | 142 | name = GSM_PhonebookGetEntryName(&entry); |
143 | if (name != NULL) { | 143 | if (name != NULL) { |
144 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); | 144 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); |
145 | } else { | 145 | } else { |
146 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); | 146 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); |
147 | } | 147 | } |
148 | } else { | 148 | } else { |
149 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); | 149 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); |
150 | } | 150 | } |
151 | #endif | 151 | #endif |
152 | break; | 152 | break; |
153 | case TODO_PHONE: | 153 | case TODO_PHONE: |
154 | #if 0 | 154 | #if 0 |
155 | // not supported | 155 | // not supported |
156 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); | 156 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); |
157 | #endif | 157 | #endif |
158 | break; | 158 | break; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | QString alarmString = ""; | 161 | QString alarmString = "na"; |
162 | if ( alarm ) { | 162 | if ( alarm ) { |
163 | Alarm *alarm; | 163 | Alarm *alarm; |
164 | if ( todo->alarms().count() > 0 ) | 164 | if ( todo->alarms().count() > 0 ) |
165 | alarm = todo->alarms().first(); | 165 | alarm = todo->alarms().first(); |
166 | else { | 166 | else { |
167 | alarm = new Alarm( todo ); | 167 | alarm = new Alarm( todo ); |
168 | todo->addAlarm( alarm ); | 168 | todo->addAlarm( alarm ); |
169 | } | 169 | } |
170 | alarm->setType( Alarm::Audio ); | 170 | alarm->setType( Alarm::Audio ); |
171 | alarm->setEnabled( true ); | 171 | alarm->setEnabled( true ); |
172 | int alarmOffset = alarmDt.secsTo( todo->dtStart() ); | 172 | int alarmOffset = alarmDt.secsTo( todo->dtStart() ); |
173 | alarm->setStartOffset( -alarmOffset ); | 173 | alarm->setStartOffset( -alarmOffset ); |
174 | alarmString = QString::number( alarmOffset ); | 174 | alarmString = QString::number( alarmOffset ); |
175 | } else { | 175 | } else { |
176 | Alarm *alarm; | 176 | Alarm *alarm; |
177 | if ( todo->alarms().count() > 0 ) { | 177 | if ( todo->alarms().count() > 0 ) { |
178 | alarm = todo->alarms().first(); | 178 | alarm = todo->alarms().first(); |
179 | alarm->setType( Alarm::Audio ); | ||
180 | alarm->setStartOffset( -60*15 ); | ||
179 | alarm->setEnabled( false ); | 181 | alarm->setEnabled( false ); |
180 | } | 182 | } |
181 | } | 183 | } |
182 | // csum ***************************************** | 184 | // csum ***************************************** |
183 | QStringList attList; | 185 | QStringList attList; |
184 | uint cSum; | 186 | uint cSum; |
185 | if ( todo->hasDueDate() ) | 187 | if ( todo->hasDueDate() ) |
186 | attList << dtToString ( todo->dtDue() ); | 188 | attList << dtToString ( todo->dtDue() ); |
187 | attList << QString::number( id ); | 189 | attList << QString::number( id ); |
188 | attList << todo->summary(); | 190 | attList << todo->summary(); |
189 | attList << completedString; | 191 | attList << completedString; |
190 | attList << QString::number( todo->priority() ); | 192 | attList << QString::number( todo->priority() ); |
191 | attList << alarmString; | 193 | attList << alarmString; |
192 | attList << todo->categoriesStr(); | 194 | attList << todo->categoriesStr(); |
193 | attList << todo->secrecyStr(); | 195 | attList << todo->secrecyStr(); |
194 | cSum = PhoneFormat::getCsum(attList ); | 196 | cSum = PhoneFormat::getCsum(attList ); |
195 | todo->setCsum( mProfileName, QString::number( cSum )); | 197 | todo->setCsum( mProfileName, QString::number( cSum )); |
196 | mCalendar->addTodo( todo); | 198 | mCalendar->addTodo( todo); |
197 | 199 | ||
198 | return true; | 200 | return true; |
199 | } | 201 | } |
200 | bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) | 202 | bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) |
201 | { | 203 | { |
202 | 204 | ||
203 | int id = Note->Location; | 205 | int id = Note->Location; |
204 | Event *event; | 206 | Event *event; |
205 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); | 207 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); |
206 | if ( event ) | 208 | if ( event ) |
207 | event = (Event*)event->clone(); | 209 | event = (Event*)event->clone(); |
208 | else | 210 | else |
209 | event = new Event; | 211 | event = new Event; |
210 | event->setID( mProfileName,QString::number( id ) ); | 212 | event->setID( mProfileName,QString::number( id ) ); |
211 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 213 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
212 | 214 | ||
213 | 215 | ||
214 | int i = 0; | 216 | int i = 0; |
215 | bool repeating = false; | 217 | bool repeating = false; |
216 | int repeat_dayofweek = -1; | 218 | int repeat_dayofweek = -1; |
217 | int repeat_day = -1; | 219 | int repeat_day = -1; |
218 | int repeat_weekofmonth = -1; | 220 | int repeat_weekofmonth = -1; |
219 | int repeat_month = -1; | 221 | int repeat_month = -1; |
220 | int repeat_frequency = -1; | 222 | int repeat_frequency = -1; |
221 | int rec_type = -1; | 223 | int rec_type = -1; |
222 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; | 224 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; |
223 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; | 225 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; |
224 | GSM_DateTime* dtp; | 226 | GSM_DateTime* dtp; |
225 | bool alarm = false; | 227 | bool alarm = false; |
226 | QDateTime alarmDt; | 228 | QDateTime alarmDt; |
227 | repeat_startdate.Day= 0; | 229 | repeat_startdate.Day= 0; |
228 | repeat_stopdate.Day = 0; | 230 | repeat_stopdate.Day = 0; |
229 | for (i=0;i<Note->EntriesNum;i++) { | 231 | for (i=0;i<Note->EntriesNum;i++) { |
230 | 232 | ||
231 | //qDebug(" for ev"); | 233 | //qDebug(" for ev"); |
232 | switch (Note->Entries[i].EntryType) { | 234 | switch (Note->Entries[i].EntryType) { |
233 | case CAL_START_DATETIME: | 235 | case CAL_START_DATETIME: |
234 | dtp = &Note->Entries[i].Date ; | 236 | dtp = &Note->Entries[i].Date ; |
235 | if ( dtp->Hour > 24 ) { | 237 | if ( dtp->Hour > 24 ) { |
236 | event->setFloats( true ); | 238 | event->setFloats( true ); |
237 | event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); | 239 | event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); |
238 | } else { | 240 | } else { |
239 | event->setDtStart (fromGSM ( dtp )); | 241 | event->setDtStart (fromGSM ( dtp )); |
240 | 242 | ||
241 | } | 243 | } |
242 | break; | 244 | break; |
243 | case CAL_END_DATETIME: | 245 | case CAL_END_DATETIME: |
244 | dtp = &Note->Entries[i].Date ; | 246 | dtp = &Note->Entries[i].Date ; |
245 | if ( dtp->Hour > 24 ) { | 247 | if ( dtp->Hour > 24 ) { |
246 | event->setFloats( true ); | 248 | event->setFloats( true ); |
247 | event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); | 249 | event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); |
248 | } else { | 250 | } else { |
249 | event->setDtEnd (fromGSM ( dtp )); | 251 | event->setDtEnd (fromGSM ( dtp )); |
250 | } | 252 | } |
251 | break; | 253 | break; |
252 | case CAL_ALARM_DATETIME: | 254 | case CAL_ALARM_DATETIME: |
253 | dtp = &Note->Entries[i].Date ; | 255 | dtp = &Note->Entries[i].Date ; |
254 | alarm = true; | 256 | alarm = true; |
255 | alarmDt = fromGSM ( dtp ); | 257 | alarmDt = fromGSM ( dtp ); |
256 | break; | 258 | break; |
257 | case CAL_SILENT_ALARM_DATETIME: | 259 | case CAL_SILENT_ALARM_DATETIME: |
258 | dtp = &Note->Entries[i].Date ; | 260 | dtp = &Note->Entries[i].Date ; |
259 | alarm = true; | 261 | alarm = true; |
260 | alarmDt = fromGSM ( dtp ); | 262 | alarmDt = fromGSM ( dtp ); |
261 | break; | 263 | break; |
262 | case CAL_RECURRANCE: | 264 | case CAL_RECURRANCE: |
263 | rec_type = Note->Entries[i].Number; | 265 | rec_type = Note->Entries[i].Number; |
264 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); | 266 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); |
265 | break; | 267 | break; |
266 | case CAL_TEXT: | 268 | case CAL_TEXT: |
267 | //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) ); | 269 | //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) ); |
268 | event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text ))); | 270 | event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text ))); |
269 | break; | 271 | break; |
270 | case CAL_LOCATION: | 272 | case CAL_LOCATION: |
271 | event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) )); | 273 | event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) )); |
272 | break; | 274 | break; |
273 | case CAL_PHONE: | 275 | case CAL_PHONE: |
274 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); | 276 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); |
@@ -348,211 +350,213 @@ public: | |||
348 | if ( repeat_day >= 0 ) | 350 | if ( repeat_day >= 0 ) |
349 | recurString += "d" + QString::number (repeat_day); | 351 | recurString += "d" + QString::number (repeat_day); |
350 | if ( repeat_weekofmonth >= 0 ) | 352 | if ( repeat_weekofmonth >= 0 ) |
351 | recurString += "w" + QString::number (repeat_weekofmonth); | 353 | recurString += "w" + QString::number (repeat_weekofmonth); |
352 | if ( repeat_month >= 0 ) | 354 | if ( repeat_month >= 0 ) |
353 | recurString += "m" + QString::number ( repeat_month ); | 355 | recurString += "m" + QString::number ( repeat_month ); |
354 | if ( repeat_frequency >= 0 ) | 356 | if ( repeat_frequency >= 0 ) |
355 | recurString += "f" + QString::number (repeat_frequency ); | 357 | recurString += "f" + QString::number (repeat_frequency ); |
356 | 358 | ||
357 | int rtype = 0; | 359 | int rtype = 0; |
358 | // qDebug("recurs "); | 360 | // qDebug("recurs "); |
359 | QDate startDate, endDate; | 361 | QDate startDate, endDate; |
360 | if ( repeat_startdate.Day > 0 ) | 362 | if ( repeat_startdate.Day > 0 ) |
361 | startDate = datefromGSM ( &repeat_startdate ); | 363 | startDate = datefromGSM ( &repeat_startdate ); |
362 | else | 364 | else |
363 | startDate = event->dtStart().date(); | 365 | startDate = event->dtStart().date(); |
364 | int freq = repeat_frequency; | 366 | int freq = repeat_frequency; |
365 | bool hasEndDate = false; | 367 | bool hasEndDate = false; |
366 | if ( repeat_stopdate.Day > 0 ) { | 368 | if ( repeat_stopdate.Day > 0 ) { |
367 | endDate = datefromGSM ( &repeat_stopdate ); | 369 | endDate = datefromGSM ( &repeat_stopdate ); |
368 | hasEndDate = true; | 370 | hasEndDate = true; |
369 | } | 371 | } |
370 | 372 | ||
371 | uint weekDaysNum = repeat_dayofweek ; | 373 | uint weekDaysNum = repeat_dayofweek ; |
372 | 374 | ||
373 | QBitArray weekDays( 7 ); | 375 | QBitArray weekDays( 7 ); |
374 | int i; | 376 | int i; |
375 | int bb = 1; | 377 | int bb = 1; |
376 | for( i = 1; i <= 7; ++i ) { | 378 | for( i = 1; i <= 7; ++i ) { |
377 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 379 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
378 | bb = 2 << (i-1); | 380 | bb = 2 << (i-1); |
379 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 381 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
380 | } | 382 | } |
381 | // qDebug("next "); | 383 | // qDebug("next "); |
382 | int pos = 0; | 384 | int pos = 0; |
383 | Recurrence *r = event->recurrence(); | 385 | Recurrence *r = event->recurrence(); |
384 | /* | 386 | /* |
385 | 0 daily; | 387 | 0 daily; |
386 | 1 weekly;x | 388 | 1 weekly;x |
387 | 2 monthpos;x | 389 | 2 monthpos;x |
388 | 3 monthlyday; | 390 | 3 monthlyday; |
389 | 4 rYearlyMont | 391 | 4 rYearlyMont |
390 | bool repeating = false; | 392 | bool repeating = false; |
391 | int repeat_dayofweek = -1; | 393 | int repeat_dayofweek = -1; |
392 | int repeat_day = -1; | 394 | int repeat_day = -1; |
393 | int repeat_weekofmonth = -1; | 395 | int repeat_weekofmonth = -1; |
394 | int repeat_month = -1; | 396 | int repeat_month = -1; |
395 | int repeat_frequency = -1; | 397 | int repeat_frequency = -1; |
396 | */ | 398 | */ |
397 | int dayOfWeek = startDate.dayOfWeek(); | 399 | int dayOfWeek = startDate.dayOfWeek(); |
398 | if ( repeat_weekofmonth >= 0 ) { | 400 | if ( repeat_weekofmonth >= 0 ) { |
399 | rtype = 2; | 401 | rtype = 2; |
400 | pos = repeat_weekofmonth; | 402 | pos = repeat_weekofmonth; |
401 | if ( repeat_dayofweek >= 0 ) | 403 | if ( repeat_dayofweek >= 0 ) |
402 | dayOfWeek = repeat_dayofweek; | 404 | dayOfWeek = repeat_dayofweek; |
403 | } else if ( repeat_dayofweek >= 0 ) { | 405 | } else if ( repeat_dayofweek >= 0 ) { |
404 | rtype = 1; | 406 | rtype = 1; |
405 | } if ( repeat_dayofweek >= 0 ) { | 407 | } if ( repeat_dayofweek >= 0 ) { |
406 | rtype = 1; | 408 | rtype = 1; |
407 | } | 409 | } |
408 | 410 | ||
409 | if ( rtype == 0 ) { | 411 | if ( rtype == 0 ) { |
410 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 412 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
411 | else r->setDaily( freq, -1 ); | 413 | else r->setDaily( freq, -1 ); |
412 | } else if ( rtype == 1 ) { | 414 | } else if ( rtype == 1 ) { |
413 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 415 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
414 | else r->setWeekly( freq, weekDays, -1 ); | 416 | else r->setWeekly( freq, weekDays, -1 ); |
415 | } else if ( rtype == 3 ) { | 417 | } else if ( rtype == 3 ) { |
416 | if ( hasEndDate ) | 418 | if ( hasEndDate ) |
417 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 419 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
418 | else | 420 | else |
419 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 421 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
420 | r->addMonthlyDay( startDate.day() ); | 422 | r->addMonthlyDay( startDate.day() ); |
421 | } else if ( rtype == 2 ) { | 423 | } else if ( rtype == 2 ) { |
422 | if ( hasEndDate ) | 424 | if ( hasEndDate ) |
423 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 425 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
424 | else | 426 | else |
425 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 427 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
426 | QBitArray days( 7 ); | 428 | QBitArray days( 7 ); |
427 | days.fill( false ); | 429 | days.fill( false ); |
428 | days.setBit( dayOfWeek - 1 ); | 430 | days.setBit( dayOfWeek - 1 ); |
429 | r->addMonthlyPos( pos, days ); | 431 | r->addMonthlyPos( pos, days ); |
430 | } else if ( rtype == 4 ) { | 432 | } else if ( rtype == 4 ) { |
431 | if ( hasEndDate ) | 433 | if ( hasEndDate ) |
432 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 434 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
433 | else | 435 | else |
434 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 436 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
435 | r->addYearlyNum( startDate.month() ); | 437 | r->addYearlyNum( startDate.month() ); |
436 | } | 438 | } |
437 | } else { | 439 | } else { |
438 | event->recurrence()->unsetRecurs(); | 440 | event->recurrence()->unsetRecurs(); |
439 | } | 441 | } |
440 | 442 | ||
441 | QStringList categoryList; | 443 | QStringList categoryList; |
442 | categoryList << getCategory( Note ); | 444 | categoryList << getCategory( Note ); |
443 | event->setCategories( categoryList ); | 445 | event->setCategories( categoryList ); |
444 | QString alarmString = ""; | 446 | QString alarmString = "na"; |
445 | // strange 0 semms to mean: alarm enabled | 447 | // strange 0 semms to mean: alarm enabled |
446 | if ( alarm ) { | 448 | if ( alarm ) { |
447 | Alarm *alarm; | 449 | Alarm *alarm; |
448 | if ( event->alarms().count() > 0 ) | 450 | if ( event->alarms().count() > 0 ) |
449 | alarm = event->alarms().first(); | 451 | alarm = event->alarms().first(); |
450 | else { | 452 | else { |
451 | alarm = new Alarm( event ); | 453 | alarm = new Alarm( event ); |
452 | event->addAlarm( alarm ); | 454 | event->addAlarm( alarm ); |
453 | } | 455 | } |
454 | alarm->setType( Alarm::Audio ); | 456 | alarm->setType( Alarm::Audio ); |
455 | alarm->setEnabled( true ); | 457 | alarm->setEnabled( true ); |
456 | int alarmOffset = alarmDt.secsTo( event->dtStart() ); | 458 | int alarmOffset = alarmDt.secsTo( event->dtStart() ); |
457 | alarm->setStartOffset( -alarmOffset ); | 459 | alarm->setStartOffset( -alarmOffset ); |
458 | alarmString = QString::number( alarmOffset ); | 460 | alarmString = QString::number( alarmOffset ); |
459 | } else { | 461 | } else { |
460 | Alarm *alarm; | 462 | Alarm *alarm; |
461 | if ( event->alarms().count() > 0 ) { | 463 | if ( event->alarms().count() > 0 ) { |
462 | alarm = event->alarms().first(); | 464 | alarm = event->alarms().first(); |
465 | alarm->setType( Alarm::Audio ); | ||
466 | alarm->setStartOffset( -60*15 ); | ||
463 | alarm->setEnabled( false ); | 467 | alarm->setEnabled( false ); |
464 | } | 468 | } |
465 | } | 469 | } |
466 | // csum ***************************************** | 470 | // csum ***************************************** |
467 | QStringList attList; | 471 | QStringList attList; |
468 | uint cSum; | 472 | uint cSum; |
469 | attList << dtToString ( event->dtStart() ); | 473 | attList << dtToString ( event->dtStart() ); |
470 | attList << dtToString ( event->dtEnd() ); | 474 | attList << dtToString ( event->dtEnd() ); |
471 | attList << QString::number( id ); | 475 | attList << QString::number( id ); |
472 | attList << event->summary(); | 476 | attList << event->summary(); |
473 | attList << event->location(); | 477 | attList << event->location(); |
474 | attList << alarmString; | 478 | attList << alarmString; |
475 | attList << recurString; | 479 | attList << recurString; |
476 | attList << event->categoriesStr(); | 480 | attList << event->categoriesStr(); |
477 | attList << event->secrecyStr(); | 481 | attList << event->secrecyStr(); |
478 | cSum = PhoneFormat::getCsum(attList ); | 482 | cSum = PhoneFormat::getCsum(attList ); |
479 | event->setCsum( mProfileName, QString::number( cSum )); | 483 | event->setCsum( mProfileName, QString::number( cSum )); |
480 | mCalendar->addEvent( event); | 484 | mCalendar->addEvent( event); |
481 | 485 | ||
482 | return true; | 486 | return true; |
483 | } | 487 | } |
484 | 488 | ||
485 | 489 | ||
486 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { | 490 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { |
487 | QDateTime dt; | 491 | QDateTime dt; |
488 | int y,m,t,h,min,sec; | 492 | int y,m,t,h,min,sec; |
489 | y = dtp->Year; | 493 | y = dtp->Year; |
490 | m = dtp->Month; | 494 | m = dtp->Month; |
491 | t = dtp->Day; | 495 | t = dtp->Day; |
492 | h = dtp->Hour; | 496 | h = dtp->Hour; |
493 | min = dtp->Minute; | 497 | min = dtp->Minute; |
494 | sec = dtp->Second; | 498 | sec = dtp->Second; |
495 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 499 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
496 | // dtp->Timezone: offset in hours | 500 | // dtp->Timezone: offset in hours |
497 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 501 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
498 | if ( useTz ) | 502 | if ( useTz ) |
499 | dt = dt.addSecs ( offset*60); | 503 | dt = dt.addSecs ( offset*60); |
500 | return dt; | 504 | return dt; |
501 | 505 | ||
502 | } | 506 | } |
503 | 507 | ||
504 | QString dtToString( const QDateTime& dti, bool useTZ = false ) | 508 | QString dtToString( const QDateTime& dti, bool useTZ = false ) |
505 | { | 509 | { |
506 | QString datestr; | 510 | QString datestr; |
507 | QString timestr; | 511 | QString timestr; |
508 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 512 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
509 | QDateTime dt; | 513 | QDateTime dt; |
510 | if (useTZ) | 514 | if (useTZ) |
511 | dt = dti.addSecs ( -(offset*60)); | 515 | dt = dti.addSecs ( -(offset*60)); |
512 | else | 516 | else |
513 | dt = dti; | 517 | dt = dti; |
514 | if(dt.date().isValid()){ | 518 | if(dt.date().isValid()){ |
515 | const QDate& date = dt.date(); | 519 | const QDate& date = dt.date(); |
516 | datestr.sprintf("%04d%02d%02d", | 520 | datestr.sprintf("%04d%02d%02d", |
517 | date.year(), date.month(), date.day()); | 521 | date.year(), date.month(), date.day()); |
518 | } | 522 | } |
519 | if(dt.time().isValid()){ | 523 | if(dt.time().isValid()){ |
520 | const QTime& time = dt.time(); | 524 | const QTime& time = dt.time(); |
521 | timestr.sprintf("T%02d%02d%02d", | 525 | timestr.sprintf("T%02d%02d%02d", |
522 | time.hour(), time.minute(), time.second()); | 526 | time.hour(), time.minute(), time.second()); |
523 | } | 527 | } |
524 | return datestr + timestr; | 528 | return datestr + timestr; |
525 | } | 529 | } |
526 | QDate datefromGSM ( GSM_DateTime*dtp ) { | 530 | QDate datefromGSM ( GSM_DateTime*dtp ) { |
527 | return QDate ( dtp->Year, dtp->Month, dtp->Day ); | 531 | return QDate ( dtp->Year, dtp->Month, dtp->Day ); |
528 | } | 532 | } |
529 | QString getCategory( GSM_CalendarEntry*Note) | 533 | QString getCategory( GSM_CalendarEntry*Note) |
530 | { | 534 | { |
531 | QString CATEGORY; | 535 | QString CATEGORY; |
532 | switch (Note->Type) { | 536 | switch (Note->Type) { |
533 | case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; | 537 | case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; |
534 | case GSM_CAL_CALL : CATEGORY = QString("Call"); break; | 538 | case GSM_CAL_CALL : CATEGORY = QString("Call"); break; |
535 | case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; | 539 | case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; |
536 | case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; | 540 | case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; |
537 | case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; | 541 | case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; |
538 | case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; | 542 | case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; |
539 | case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; | 543 | case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; |
540 | case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; | 544 | case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; |
541 | case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; | 545 | case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; |
542 | case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; | 546 | case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; |
543 | case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; | 547 | case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; |
544 | case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; | 548 | case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; |
545 | case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; | 549 | case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; |
546 | case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; | 550 | case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; |
547 | case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; | 551 | case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; |
548 | case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; | 552 | case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; |
549 | case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; | 553 | case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; |
550 | case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; | 554 | case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; |
551 | case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; | 555 | case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; |
552 | case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; | 556 | case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; |
553 | case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; | 557 | case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; |
554 | case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; | 558 | case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; |
555 | case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; | 559 | case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; |
556 | case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; | 560 | case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; |
557 | case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; | 561 | case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; |
558 | case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; | 562 | case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index f8b066d..defdb09 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -96,192 +96,194 @@ class SharpParser : public QObject | |||
96 | 96 | ||
97 | event->setSummary( attList[2] ); | 97 | event->setSummary( attList[2] ); |
98 | event->setLocation( attList[3] ); | 98 | event->setLocation( attList[3] ); |
99 | event->setDescription( attList[4] ); | 99 | event->setDescription( attList[4] ); |
100 | if ( attList[7] == "1" ) { | 100 | if ( attList[7] == "1" ) { |
101 | event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); | 101 | event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); |
102 | event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); | 102 | event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); |
103 | event->setFloats( true ); | 103 | event->setFloats( true ); |
104 | } else { | 104 | } else { |
105 | event->setFloats( false ); | 105 | event->setFloats( false ); |
106 | event->setDtStart( fromString( attList[5] ) ); | 106 | event->setDtStart( fromString( attList[5] ) ); |
107 | event->setDtEnd( fromString( attList[6] )); | 107 | event->setDtEnd( fromString( attList[6] )); |
108 | } | 108 | } |
109 | 109 | ||
110 | QString rtype = attList[11]; | 110 | QString rtype = attList[11]; |
111 | if ( rtype != "255" ) { | 111 | if ( rtype != "255" ) { |
112 | // qDebug("recurs "); | 112 | // qDebug("recurs "); |
113 | QDate startDate = event->dtStart().date(); | 113 | QDate startDate = event->dtStart().date(); |
114 | 114 | ||
115 | QString freqStr = attList[12]; | 115 | QString freqStr = attList[12]; |
116 | int freq = freqStr.toInt(); | 116 | int freq = freqStr.toInt(); |
117 | 117 | ||
118 | QString hasEndDateStr = attList[15] ; | 118 | QString hasEndDateStr = attList[15] ; |
119 | bool hasEndDate = hasEndDateStr == "1"; | 119 | bool hasEndDate = hasEndDateStr == "1"; |
120 | 120 | ||
121 | QString endDateStr = attList[16]; | 121 | QString endDateStr = attList[16]; |
122 | QDate endDate = fromString( endDateStr ).date(); | 122 | QDate endDate = fromString( endDateStr ).date(); |
123 | 123 | ||
124 | QString weekDaysStr = attList[14]; | 124 | QString weekDaysStr = attList[14]; |
125 | uint weekDaysNum = weekDaysStr.toInt(); | 125 | uint weekDaysNum = weekDaysStr.toInt(); |
126 | 126 | ||
127 | QBitArray weekDays( 7 ); | 127 | QBitArray weekDays( 7 ); |
128 | int i; | 128 | int i; |
129 | int bb = 1; | 129 | int bb = 1; |
130 | for( i = 1; i <= 7; ++i ) { | 130 | for( i = 1; i <= 7; ++i ) { |
131 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 131 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
132 | bb = 2 << (i-1); | 132 | bb = 2 << (i-1); |
133 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 133 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
134 | } | 134 | } |
135 | // qDebug("next "); | 135 | // qDebug("next "); |
136 | QString posStr = attList[13]; | 136 | QString posStr = attList[13]; |
137 | int pos = posStr.toInt(); | 137 | int pos = posStr.toInt(); |
138 | Recurrence *r = event->recurrence(); | 138 | Recurrence *r = event->recurrence(); |
139 | 139 | ||
140 | if ( rtype == "0" ) { | 140 | if ( rtype == "0" ) { |
141 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 141 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
142 | else r->setDaily( freq, -1 ); | 142 | else r->setDaily( freq, -1 ); |
143 | } else if ( rtype == "1" ) { | 143 | } else if ( rtype == "1" ) { |
144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
145 | else r->setWeekly( freq, weekDays, -1 ); | 145 | else r->setWeekly( freq, weekDays, -1 ); |
146 | } else if ( rtype == "3" ) { | 146 | } else if ( rtype == "3" ) { |
147 | if ( hasEndDate ) | 147 | if ( hasEndDate ) |
148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
149 | else | 149 | else |
150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
151 | r->addMonthlyDay( startDate.day() ); | 151 | r->addMonthlyDay( startDate.day() ); |
152 | } else if ( rtype == "2" ) { | 152 | } else if ( rtype == "2" ) { |
153 | if ( hasEndDate ) | 153 | if ( hasEndDate ) |
154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
155 | else | 155 | else |
156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
157 | QBitArray days( 7 ); | 157 | QBitArray days( 7 ); |
158 | days.fill( false ); | 158 | days.fill( false ); |
159 | days.setBit( startDate.dayOfWeek() - 1 ); | 159 | days.setBit( startDate.dayOfWeek() - 1 ); |
160 | r->addMonthlyPos( pos, days ); | 160 | r->addMonthlyPos( pos, days ); |
161 | } else if ( rtype == "4" ) { | 161 | } else if ( rtype == "4" ) { |
162 | if ( hasEndDate ) | 162 | if ( hasEndDate ) |
163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
164 | else | 164 | else |
165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
166 | r->addYearlyNum( startDate.month() ); | 166 | r->addYearlyNum( startDate.month() ); |
167 | } | 167 | } |
168 | } else { | 168 | } else { |
169 | event->recurrence()->unsetRecurs(); | 169 | event->recurrence()->unsetRecurs(); |
170 | } | 170 | } |
171 | 171 | ||
172 | QString categoryList = attList[1] ; | 172 | QString categoryList = attList[1] ; |
173 | event->setCategories( lookupCategories( categoryList ) ); | 173 | event->setCategories( lookupCategories( categoryList ) ); |
174 | 174 | ||
175 | // strange 0 semms to mean: alarm enabled | 175 | // strange 0 semms to mean: alarm enabled |
176 | if ( attList[8] == "0" ) { | 176 | if ( attList[8] == "0" ) { |
177 | Alarm *alarm; | 177 | Alarm *alarm; |
178 | if ( event->alarms().count() > 0 ) | 178 | if ( event->alarms().count() > 0 ) |
179 | alarm = event->alarms().first(); | 179 | alarm = event->alarms().first(); |
180 | else { | 180 | else { |
181 | alarm = new Alarm( event ); | 181 | alarm = new Alarm( event ); |
182 | event->addAlarm( alarm ); | 182 | event->addAlarm( alarm ); |
183 | } | 183 | } |
184 | alarm->setType( Alarm::Audio ); | 184 | alarm->setType( Alarm::Audio ); |
185 | alarm->setEnabled( true ); | 185 | alarm->setEnabled( true ); |
186 | int alarmOffset = attList[9].toInt(); | 186 | int alarmOffset = attList[9].toInt(); |
187 | alarm->setStartOffset( alarmOffset * -60 ); | 187 | alarm->setStartOffset( alarmOffset * -60 ); |
188 | } else { | 188 | } else { |
189 | Alarm *alarm; | 189 | Alarm *alarm; |
190 | if ( event->alarms().count() > 0 ) { | 190 | if ( event->alarms().count() > 0 ) { |
191 | alarm = event->alarms().first(); | 191 | alarm = event->alarms().first(); |
192 | alarm->setType( Alarm::Audio ); | ||
193 | alarm->setStartOffset( -60*15 ); | ||
192 | alarm->setEnabled( false ); | 194 | alarm->setEnabled( false ); |
193 | } | 195 | } |
194 | } | 196 | } |
195 | 197 | ||
196 | mCalendar->addEvent( event); | 198 | mCalendar->addEvent( event); |
197 | } else if ( qName == "Todo" ) { | 199 | } else if ( qName == "Todo" ) { |
198 | Todo *todo; | 200 | Todo *todo; |
199 | 201 | ||
200 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); | 202 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); |
201 | if (todo ) | 203 | if (todo ) |
202 | todo = (Todo*)todo->clone(); | 204 | todo = (Todo*)todo->clone(); |
203 | else | 205 | else |
204 | todo = new Todo; | 206 | todo = new Todo; |
205 | 207 | ||
206 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | 208 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 |
207 | // 0 1 2 3 4 5 6 7 8 | 209 | // 0 1 2 3 4 5 6 7 8 |
208 | //1,,,,,1,4,Loch zumachen,"" | 210 | //1,,,,,1,4,Loch zumachen,"" |
209 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | 211 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " |
210 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | 212 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes |
211 | 213 | ||
212 | todo->setID( "Sharp_DTM", attList[0]); | 214 | todo->setID( "Sharp_DTM", attList[0]); |
213 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); | 215 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); |
214 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 216 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
215 | 217 | ||
216 | todo->setSummary( attList[7] ); | 218 | todo->setSummary( attList[7] ); |
217 | todo->setDescription( attList[8]); | 219 | todo->setDescription( attList[8]); |
218 | 220 | ||
219 | int priority = attList[6].toInt(); | 221 | int priority = attList[6].toInt(); |
220 | if ( priority == 0 ) priority = 3; | 222 | if ( priority == 0 ) priority = 3; |
221 | todo->setPriority( priority ); | 223 | todo->setPriority( priority ); |
222 | 224 | ||
223 | QString categoryList = attList[1]; | 225 | QString categoryList = attList[1]; |
224 | todo->setCategories( lookupCategories( categoryList ) ); | 226 | todo->setCategories( lookupCategories( categoryList ) ); |
225 | 227 | ||
226 | 228 | ||
227 | 229 | ||
228 | QString hasDateStr = attList[3]; // due | 230 | QString hasDateStr = attList[3]; // due |
229 | if ( !hasDateStr.isEmpty() ) { | 231 | if ( !hasDateStr.isEmpty() ) { |
230 | if ( hasDateStr.right(6) == "000000" ) { | 232 | if ( hasDateStr.right(6) == "000000" ) { |
231 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); | 233 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); |
232 | todo->setFloats( true ); | 234 | todo->setFloats( true ); |
233 | } | 235 | } |
234 | else { | 236 | else { |
235 | todo->setDtDue( fromString( hasDateStr ) ); | 237 | todo->setDtDue( fromString( hasDateStr ) ); |
236 | todo->setFloats( false ); | 238 | todo->setFloats( false ); |
237 | } | 239 | } |
238 | 240 | ||
239 | todo->setHasDueDate( true ); | 241 | todo->setHasDueDate( true ); |
240 | } | 242 | } |
241 | hasDateStr = attList[2];//start | 243 | hasDateStr = attList[2];//start |
242 | if ( !hasDateStr.isEmpty() ) { | 244 | if ( !hasDateStr.isEmpty() ) { |
243 | 245 | ||
244 | todo->setDtStart( fromString( hasDateStr ) ); | 246 | todo->setDtStart( fromString( hasDateStr ) ); |
245 | todo->setHasStartDate( true); | 247 | todo->setHasStartDate( true); |
246 | } else | 248 | } else |
247 | todo->setHasStartDate( false ); | 249 | todo->setHasStartDate( false ); |
248 | hasDateStr = attList[4];//completed | 250 | hasDateStr = attList[4];//completed |
249 | if ( !hasDateStr.isEmpty() ) { | 251 | if ( !hasDateStr.isEmpty() ) { |
250 | todo->setCompleted(fromString( hasDateStr ) ); | 252 | todo->setCompleted(fromString( hasDateStr ) ); |
251 | } | 253 | } |
252 | QString completedStr = attList[5]; | 254 | QString completedStr = attList[5]; |
253 | if ( completedStr == "0" ) | 255 | if ( completedStr == "0" ) |
254 | todo->setCompleted( true ); | 256 | todo->setCompleted( true ); |
255 | else | 257 | else |
256 | todo->setCompleted( false ); | 258 | todo->setCompleted( false ); |
257 | mCalendar->addTodo( todo ); | 259 | mCalendar->addTodo( todo ); |
258 | 260 | ||
259 | } else if ( qName == "Category" ) { | 261 | } else if ( qName == "Category" ) { |
260 | /* | 262 | /* |
261 | QString id = attributes.value( "id" ); | 263 | QString id = attributes.value( "id" ); |
262 | QString name = attributes.value( "name" ); | 264 | QString name = attributes.value( "name" ); |
263 | setCategory( id, name ); | 265 | setCategory( id, name ); |
264 | */ | 266 | */ |
265 | } | 267 | } |
266 | //qDebug("end "); | 268 | //qDebug("end "); |
267 | return true; | 269 | return true; |
268 | } | 270 | } |
269 | 271 | ||
270 | 272 | ||
271 | void setCategoriesList ( QStringList * c ) | 273 | void setCategoriesList ( QStringList * c ) |
272 | { | 274 | { |
273 | oldCategories = c; | 275 | oldCategories = c; |
274 | } | 276 | } |
275 | 277 | ||
276 | QDateTime fromString ( QString s, bool useTz = true ) { | 278 | QDateTime fromString ( QString s, bool useTz = true ) { |
277 | QDateTime dt; | 279 | QDateTime dt; |
278 | int y,m,t,h,min,sec; | 280 | int y,m,t,h,min,sec; |
279 | y = s.mid(0,4).toInt(); | 281 | y = s.mid(0,4).toInt(); |
280 | m = s.mid(4,2).toInt(); | 282 | m = s.mid(4,2).toInt(); |
281 | t = s.mid(6,2).toInt(); | 283 | t = s.mid(6,2).toInt(); |
282 | h = s.mid(9,2).toInt(); | 284 | h = s.mid(9,2).toInt(); |
283 | min = s.mid(11,2).toInt(); | 285 | min = s.mid(11,2).toInt(); |
284 | sec = s.mid(13,2).toInt(); | 286 | sec = s.mid(13,2).toInt(); |
285 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 287 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
286 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 288 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
287 | if ( useTz ) | 289 | if ( useTz ) |