author | zautrix <zautrix> | 2005-07-26 19:03:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-26 19:03:31 (UTC) |
commit | c7b8804b49e463d42f0bd5aec4b638187190417a (patch) (unidiff) | |
tree | 2941cd5b9df04c96cc18800acf5df9d320c167d8 /korganizer | |
parent | d0fe94073aa3209532952c944b41bccfb4341a8d (diff) | |
download | kdepimpi-c7b8804b49e463d42f0bd5aec4b638187190417a.zip kdepimpi-c7b8804b49e463d42f0bd5aec4b638187190417a.tar.gz kdepimpi-c7b8804b49e463d42f0bd5aec4b638187190417a.tar.bz2 |
ol fix
-rw-r--r-- | korganizer/koimportoldialog.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/korganizer/koimportoldialog.cpp b/korganizer/koimportoldialog.cpp index 2af436c..79b97e8 100644 --- a/korganizer/koimportoldialog.cpp +++ b/korganizer/koimportoldialog.cpp | |||
@@ -158,228 +158,228 @@ void KOImportOLdialog::addFolder(OLEListViewItem* iParent, LPDISPATCH dispParent | |||
158 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); | 158 | hChild = new OLEListViewItem( iParent , QString::fromUcs2( szName.GetBuffer() ) ); |
159 | if ( iType != 1) | 159 | if ( iType != 1) |
160 | hChild->setEnabled( false ); | 160 | hChild->setEnabled( false ); |
161 | QString ts; | 161 | QString ts; |
162 | switch( iType ) { | 162 | switch( iType ) { |
163 | case 0: | 163 | case 0: |
164 | ts = i18n("Mail"); | 164 | ts = i18n("Mail"); |
165 | break; | 165 | break; |
166 | case 1: | 166 | case 1: |
167 | ts = i18n("Calendar"); | 167 | ts = i18n("Calendar"); |
168 | break; | 168 | break; |
169 | case 2: | 169 | case 2: |
170 | ts = i18n("Contacts"); | 170 | ts = i18n("Contacts"); |
171 | break; | 171 | break; |
172 | case 3: | 172 | case 3: |
173 | ts = i18n("Todos"); | 173 | ts = i18n("Todos"); |
174 | break; | 174 | break; |
175 | case 4: | 175 | case 4: |
176 | ts = i18n("Journals"); | 176 | ts = i18n("Journals"); |
177 | break; | 177 | break; |
178 | case 5: | 178 | case 5: |
179 | ts = i18n("Notes"); | 179 | ts = i18n("Notes"); |
180 | break; | 180 | break; |
181 | default: | 181 | default: |
182 | ts = i18n("Unknown"); | 182 | ts = i18n("Unknown"); |
183 | } | 183 | } |
184 | hChild->setText( 1,ts); | 184 | hChild->setText( 1,ts); |
185 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); | 185 | hChild->setData( (DWORD) mfChild.m_lpDispatch ); |
186 | mfChild.m_lpDispatch->AddRef(); | 186 | mfChild.m_lpDispatch->AddRef(); |
187 | addFolder(hChild, mfChild.m_lpDispatch); | 187 | addFolder(hChild, mfChild.m_lpDispatch); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | void KOImportOLdialog::slotApply() | 191 | void KOImportOLdialog::slotApply() |
192 | { | 192 | { |
193 | importedItems = 0; | 193 | importedItems = 0; |
194 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); | 194 | OLEListViewItem* child = (OLEListViewItem*) mListView->firstChild(); |
195 | while ( child ) { | 195 | while ( child ) { |
196 | if ( child->isOn()&& child->data() ) | 196 | if ( child->isOn()&& child->data() ) |
197 | readCalendarData( child->data() ); | 197 | readCalendarData( child->data() ); |
198 | child = (OLEListViewItem*) child->itemBelow(); | 198 | child = (OLEListViewItem*) child->itemBelow(); |
199 | } | 199 | } |
200 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); | 200 | QString mes = i18n("Importing complete.\n\n%1 items imported.").arg( importedItems); |
201 | KMessageBox::information(this,mes); | 201 | KMessageBox::information(this,mes); |
202 | } | 202 | } |
203 | void KOImportOLdialog::readCalendarData( DWORD folder ) | 203 | void KOImportOLdialog::readCalendarData( DWORD folder ) |
204 | { | 204 | { |
205 | 205 | ||
206 | LPDISPATCH dispItem = (LPDISPATCH)folder; | 206 | LPDISPATCH dispItem = (LPDISPATCH)folder; |
207 | dispItem->AddRef(); | 207 | dispItem->AddRef(); |
208 | MAPIFolder mf(dispItem); | 208 | MAPIFolder mf(dispItem); |
209 | mf.m_lpDispatch->AddRef(); | 209 | mf.m_lpDispatch->AddRef(); |
210 | _Items folderItems; | 210 | _Items folderItems; |
211 | _variant_t indx((long)0); | 211 | _variant_t indx((long)0); |
212 | LPDISPATCH itm; | 212 | LPDISPATCH itm; |
213 | int i; | 213 | int i; |
214 | folderItems = mf.GetItems(); | 214 | folderItems = mf.GetItems(); |
215 | QProgressDialog bar( i18n("Importing calendar data"),i18n("Abort"), folderItems.GetCount(),this ); | 215 | QProgressDialog bar( i18n("Importing calendar data"),i18n("Abort"), folderItems.GetCount(),this ); |
216 | bar.setCaption (i18n("Importing!") ); | 216 | bar.setCaption (i18n("Importing!") ); |
217 | int h = bar.sizeHint().height() ; | 217 | int h = bar.sizeHint().height() ; |
218 | int w = 300; | 218 | int w = 300; |
219 | int dw = QApplication::desktop()->width(); | 219 | int dw = QApplication::desktop()->width(); |
220 | int dh = QApplication::desktop()->height(); | 220 | int dh = QApplication::desktop()->height(); |
221 | //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 221 | //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
222 | bar.show(); | 222 | bar.show(); |
223 | for(i=1; i <= folderItems.GetCount(); ++i) | 223 | for(i=1; i <= folderItems.GetCount(); ++i) |
224 | { | 224 | { |
225 | qApp->processEvents(); | 225 | qApp->processEvents(); |
226 | if ( ! bar.isVisible() ) | 226 | if ( ! bar.isVisible() ) |
227 | return ; | 227 | return ; |
228 | bar.setProgress( i ); | 228 | bar.setProgress( i ); |
229 | bar.raise(); | 229 | bar.raise(); |
230 | indx = (long)i; | 230 | indx = (long)i; |
231 | itm = folderItems.Item(indx.Detach()); | 231 | itm = folderItems.Item(indx.Detach()); |
232 | _AppointmentItem * pItem = (_AppointmentItem *)&itm; | 232 | _AppointmentItem * pItem = (_AppointmentItem *)&itm; |
233 | ol2kopiCalendar( pItem ); | 233 | ol2kopiCalendar( pItem ); |
234 | itm->Release(); | 234 | itm->Release(); |
235 | } | 235 | } |
236 | } | 236 | } |
237 | void KOImportOLdialog::slotOk() | 237 | void KOImportOLdialog::slotOk() |
238 | { | 238 | { |
239 | QDialog::accept(); | 239 | QDialog::accept(); |
240 | } | 240 | } |
241 | 241 | ||
242 | void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRecurrence ) | 242 | void KOImportOLdialog::ol2kopiCalendar( _AppointmentItem * aItem, bool computeRecurrence ) |
243 | { | 243 | { |
244 | KCal::Event* event = new KCal::Event(); | 244 | KCal::Event* event = new KCal::Event(); |
245 | if ( aItem->GetAllDayEvent() ){ | 245 | if ( aItem->GetAllDayEvent() ){ |
246 | event->setDtStart( QDateTime( mDdate2Qdtr( aItem->GetStart()).date(),QTime(0,0,0 ) )); | 246 | event->setDtStart( QDateTime( mDdate2Qdtr( aItem->GetStart()).date(),QTime(0,0,0 ) )); |
247 | event->setDtEnd( QDateTime( mDdate2Qdtr( aItem->GetEnd()) .date(),QTime(0,0,0 )).addDays(-1)); | 247 | event->setDtEnd( QDateTime( mDdate2Qdtr( aItem->GetEnd()) .date(),QTime(0,0,0 )).addDays(-1)); |
248 | event->setFloats( true ); | 248 | event->setFloats( true ); |
249 | } else { | 249 | } else { |
250 | event->setDtStart( mDdate2Qdtr( aItem->GetStart()) ); | 250 | event->setDtStart( mDdate2Qdtr( aItem->GetStart()) ); |
251 | event->setDtEnd( mDdate2Qdtr( aItem->GetEnd()) ); | 251 | event->setDtEnd( mDdate2Qdtr( aItem->GetEnd()) ); |
252 | event->setFloats( false ); | 252 | event->setFloats( false ); |
253 | } | 253 | } |
254 | event->setSummary( QString::fromUcs2( aItem->GetSubject().GetBuffer()) ); | 254 | event->setSummary( QString::fromUcs2( aItem->GetSubject().GetBuffer()).stripWhiteSpace() ); |
255 | event->setLocation( QString::fromUcs2( aItem->GetLocation().GetBuffer()) ); | 255 | event->setLocation( QString::fromUcs2( aItem->GetLocation().GetBuffer()).stripWhiteSpace() ); |
256 | event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()).replace( QRegExp("\\r"), "") ); | 256 | event->setDescription( QString::fromUcs2( aItem->GetBody().GetBuffer()).replace( QRegExp("\\r"), "").stripWhiteSpace() ); |
257 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("; "), ";"); | 257 | QString cat = QString::fromUcs2( aItem->GetCategories().GetBuffer()).replace( QRegExp("; "), ";"); |
258 | event->setCategories( QStringList::split( ";", cat ) ); | 258 | event->setCategories( QStringList::split( ";", cat ) ); |
259 | if ( aItem->GetReminderSet() ) { | 259 | if ( aItem->GetReminderSet() ) { |
260 | event->clearAlarms(); | 260 | event->clearAlarms(); |
261 | Alarm* alarm = event->newAlarm(); | 261 | Alarm* alarm = event->newAlarm(); |
262 | alarm->setStartOffset( -aItem->GetReminderMinutesBeforeStart()*60 ); | 262 | alarm->setStartOffset( -aItem->GetReminderMinutesBeforeStart()*60 ); |
263 | alarm->setEnabled( true ); | 263 | alarm->setEnabled( true ); |
264 | if ( aItem->GetReminderPlaySound() ) { | 264 | if ( aItem->GetReminderPlaySound() ) { |
265 | alarm->setType( Alarm::Audio ); | 265 | alarm->setType( Alarm::Audio ); |
266 | alarm->setAudioFile( QString::fromUcs2( aItem->GetReminderSoundFile().GetBuffer())); | 266 | alarm->setAudioFile( QString::fromUcs2( aItem->GetReminderSoundFile().GetBuffer())); |
267 | } | 267 | } |
268 | else | 268 | else |
269 | alarm->setType( Alarm::Display ); | 269 | alarm->setType( Alarm::Display ); |
270 | alarm->setRepeatCount( aItem->GetReplyTime() ); | 270 | alarm->setRepeatCount( aItem->GetReplyTime() ); |
271 | } | 271 | } |
272 | // OL :pub 0 - pers 1 - priv 2 - conf 3 | 272 | // OL :pub 0 - pers 1 - priv 2 - conf 3 |
273 | // KO : pub 0 - priv 1 - conf 2 | 273 | // KO : pub 0 - priv 1 - conf 2 |
274 | int sec = aItem->GetSensitivity() ; | 274 | int sec = aItem->GetSensitivity() ; |
275 | if ( sec > 1 )// mapping pers -> private | 275 | if ( sec > 1 )// mapping pers -> private |
276 | --sec; | 276 | --sec; |
277 | event->setSecrecy( sec ); | 277 | event->setSecrecy( sec ); |
278 | if ( aItem->GetBusyStatus() == 0 ) | 278 | if ( aItem->GetBusyStatus() == 0 ) |
279 | event->setTransparency( Event::Transparent);// OL free | 279 | event->setTransparency( Event::Transparent);// OL free |
280 | else | 280 | else |
281 | event->setTransparency( Event::Opaque);//OL all other | 281 | event->setTransparency( Event::Opaque);//OL all other |
282 | 282 | ||
283 | if ( aItem->GetIsRecurring() && computeRecurrence ) { //recur | 283 | if ( aItem->GetIsRecurring() && computeRecurrence ) { //recur |
284 | 284 | ||
285 | RecurrencePattern recpat = aItem->GetRecurrencePattern(); | 285 | RecurrencePattern recpat = aItem->GetRecurrencePattern(); |
286 | 286 | ||
287 | QDate startDate = mDdate2Qdtr(recpat.GetPatternStartDate()).date(); | 287 | QDate startDate = mDdate2Qdtr(recpat.GetPatternStartDate()).date(); |
288 | int freq = recpat.GetInterval(); | 288 | int freq = recpat.GetInterval(); |
289 | 289 | if ( freq == 0 ) freq = 1; | |
290 | bool hasEndDate = !recpat.GetNoEndDate(); | 290 | bool hasEndDate = !recpat.GetNoEndDate(); |
291 | QDate endDate = mDdate2Qdtr(recpat.GetPatternEndDate()).date(); | 291 | QDate endDate = mDdate2Qdtr(recpat.GetPatternEndDate()).date(); |
292 | QBitArray weekDays( 7 ); | 292 | QBitArray weekDays( 7 ); |
293 | weekDays.fill(false ); | 293 | weekDays.fill(false ); |
294 | uint weekDaysNum = recpat.GetDayOfWeekMask(); | 294 | uint weekDaysNum = recpat.GetDayOfWeekMask(); |
295 | int i; | 295 | int i; |
296 | int bb = 2; | 296 | int bb = 2; |
297 | for( i = 1; i <= 6; ++i ) { | 297 | for( i = 1; i <= 6; ++i ) { |
298 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 298 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
299 | bb = 4 << (i-1); | 299 | bb = 4 << (i-1); |
300 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 300 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
301 | } | 301 | } |
302 | if ( 1 & weekDaysNum) | 302 | if ( 1 & weekDaysNum) |
303 | weekDays.setBit( 6 ); | 303 | weekDays.setBit( 6 ); |
304 | // int pos = 1;// pending | 304 | // int pos = 1;// pending |
305 | 305 | ||
306 | Recurrence *r = event->recurrence(); | 306 | Recurrence *r = event->recurrence(); |
307 | int rtype = recpat.GetRecurrenceType(); | 307 | int rtype = recpat.GetRecurrenceType(); |
308 | //recurrence types are: | 308 | //recurrence types are: |
309 | /* | 309 | /* |
310 | olRecursDaily(0) | 310 | olRecursDaily(0) |
311 | olRecursWeekly(1) | 311 | olRecursWeekly(1) |
312 | olRecursMonthly(2) | 312 | olRecursMonthly(2) |
313 | olRecursMonthNth(3) | 313 | olRecursMonthNth(3) |
314 | olRecursYearly(5) | 314 | olRecursYearly(5) |
315 | olRecursYearNth(6) | 315 | olRecursYearNth(6) |
316 | */ | 316 | */ |
317 | 317 | ||
318 | int duration = recpat.GetOccurrences(); | 318 | int duration = recpat.GetOccurrences(); |
319 | if ( !hasEndDate ) | 319 | if ( !hasEndDate ) |
320 | duration = -1; | 320 | duration = -1; |
321 | 321 | ||
322 | //LPDISPATCH RecurrencePattern::GetExceptions() | 322 | //LPDISPATCH RecurrencePattern::GetExceptions() |
323 | //long RecurrencePattern::GetMonthOfYear() | 323 | //long RecurrencePattern::GetMonthOfYear() |
324 | if ( rtype == 0 ) { | 324 | if ( rtype == 0 ) { |
325 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 325 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
326 | else r->setDaily( freq, duration ); | 326 | else r->setDaily( freq, duration ); |
327 | } else if ( rtype == 1 ) { | 327 | } else if ( rtype == 1 ) { |
328 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 328 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
329 | else r->setWeekly( freq, weekDays, duration ); | 329 | else r->setWeekly( freq, weekDays, duration ); |
330 | } else if ( rtype == 2 ) { | 330 | } else if ( rtype == 2 ) { |
331 | if ( hasEndDate ) | 331 | if ( hasEndDate ) |
332 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 332 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
333 | else | 333 | else |
334 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); | 334 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); |
335 | //r->addMonthlyDay( startDate.day() ); | 335 | //r->addMonthlyDay( startDate.day() ); |
336 | r->addMonthlyDay( recpat.GetDayOfMonth() ); | 336 | r->addMonthlyDay( recpat.GetDayOfMonth() ); |
337 | } else if ( rtype == 3 ) { | 337 | } else if ( rtype == 3 ) { |
338 | if ( hasEndDate ) | 338 | if ( hasEndDate ) |
339 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 339 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
340 | else | 340 | else |
341 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 341 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
342 | QBitArray days( 7 ); | 342 | QBitArray days( 7 ); |
343 | days.fill( false ); | 343 | days.fill( false ); |
344 | days.setBit( startDate.dayOfWeek() - 1 ); | 344 | days.setBit( startDate.dayOfWeek() - 1 ); |
345 | int pos = (startDate.day()/7)+1; | 345 | int pos = (startDate.day()/7)+1; |
346 | r->addMonthlyPos( pos, days ); | 346 | r->addMonthlyPos( pos, days ); |
347 | //QString mes = i18n("Importing monthlypos.\n\npos: %1 , day: %2").arg( pos).arg( startDate.dayOfWeek() - 1); | 347 | //QString mes = i18n("Importing monthlypos.\n\npos: %1 , day: %2").arg( pos).arg( startDate.dayOfWeek() - 1); |
348 | //KMessageBox::information(this,mes); | 348 | //KMessageBox::information(this,mes); |
349 | } else if ( rtype == 5 ) { | 349 | } else if ( rtype == 5 ) { |
350 | freq = 1; | 350 | freq = 1; |
351 | if ( hasEndDate ) | 351 | if ( hasEndDate ) |
352 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 352 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
353 | else | 353 | else |
354 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | 354 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); |
355 | r->addYearlyNum( startDate.month() ); | 355 | r->addYearlyNum( startDate.month() ); |
356 | } else if ( true /*rtype == 6*/ ) { | 356 | } else if ( true /*rtype == 6*/ ) { |
357 | // KOganizer cannot handle this in the GUI | 357 | // KOganizer cannot handle this in the GUI |
358 | // we are mapping this to monthly - every 12. month | 358 | // we are mapping this to monthly - every 12. month |
359 | freq = 12; | 359 | freq = 12; |
360 | if ( hasEndDate ) | 360 | if ( hasEndDate ) |
361 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 361 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
362 | else | 362 | else |
363 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 363 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
364 | QBitArray days( 7 ); | 364 | QBitArray days( 7 ); |
365 | days.fill( false ); | 365 | days.fill( false ); |
366 | days.setBit( startDate.dayOfWeek() - 1 ); | 366 | days.setBit( startDate.dayOfWeek() - 1 ); |
367 | int pos = (startDate.day()/7)+1; | 367 | int pos = (startDate.day()/7)+1; |
368 | r->addMonthlyPos( pos, days ); | 368 | r->addMonthlyPos( pos, days ); |
369 | } | 369 | } |
370 | // recurrence exceptions | 370 | // recurrence exceptions |
371 | LPDISPATCH dispItem = recpat.GetExceptions(); | 371 | LPDISPATCH dispItem = recpat.GetExceptions(); |
372 | dispItem->AddRef(); | 372 | dispItem->AddRef(); |
373 | Exceptions ex(dispItem); | 373 | Exceptions ex(dispItem); |
374 | _variant_t indx((long)0); | 374 | _variant_t indx((long)0); |
375 | LPDISPATCH itm; | 375 | LPDISPATCH itm; |
376 | for(i=1; i <= ex.GetCount(); ++i) { | 376 | for(i=1; i <= ex.GetCount(); ++i) { |
377 | indx = (long)i; | 377 | indx = (long)i; |
378 | itm = ex.Item( indx.Detach() ); | 378 | itm = ex.Item( indx.Detach() ); |
379 | ::Exception * pItem = (::Exception *)&itm; | 379 | ::Exception * pItem = (::Exception *)&itm; |
380 | event->addExDate( QDateTime( mDdate2Qdtr( pItem->GetOriginalDate())).date() ); | 380 | event->addExDate( QDateTime( mDdate2Qdtr( pItem->GetOriginalDate())).date() ); |
381 | if ( !pItem->GetDeleted() ) { | 381 | if ( !pItem->GetDeleted() ) { |
382 | LPDISPATCH appIt = pItem->GetAppointmentItem(); | 382 | LPDISPATCH appIt = pItem->GetAppointmentItem(); |
383 | _AppointmentItem * paItem = (_AppointmentItem *)&appIt; | 383 | _AppointmentItem * paItem = (_AppointmentItem *)&appIt; |
384 | ol2kopiCalendar( paItem, false ); | 384 | ol2kopiCalendar( paItem, false ); |
385 | } | 385 | } |