-rw-r--r-- | korganizer/calendarview.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8269910..7566b22 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -219,1621 +219,1622 @@ MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Inciden | |||
219 | mText +="</table>"; | 219 | mText +="</table>"; |
220 | setText( mText ); | 220 | setText( mText ); |
221 | } | 221 | } |
222 | 222 | ||
223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 223 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
224 | { | 224 | { |
225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 225 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
226 | } | 226 | } |
227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 227 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
228 | { | 228 | { |
229 | QDateTime dt ; | 229 | QDateTime dt ; |
230 | Incidence * retInc; | 230 | Incidence * retInc; |
231 | Incidence * inc = mAlarms.first(); | 231 | Incidence * inc = mAlarms.first(); |
232 | if ( inc == 0 ) | 232 | if ( inc == 0 ) |
233 | return 0; | 233 | return 0; |
234 | bool ok; | 234 | bool ok; |
235 | dt = inc->getNextOccurence( start, &ok ); | 235 | dt = inc->getNextOccurence( start, &ok ); |
236 | if ( ! ok ) return 0; | 236 | if ( ! ok ) return 0; |
237 | QDateTime dtn ; | 237 | QDateTime dtn ; |
238 | retInc = inc; | 238 | retInc = inc; |
239 | inc = mAlarms.next(); | 239 | inc = mAlarms.next(); |
240 | while ( inc ) { | 240 | while ( inc ) { |
241 | dtn = inc->getNextOccurence( start, &ok ); | 241 | dtn = inc->getNextOccurence( start, &ok ); |
242 | if ( ! ok ) return 0; | 242 | if ( ! ok ) return 0; |
243 | if ( dtn < dt ) { | 243 | if ( dtn < dt ) { |
244 | dt = dtn; | 244 | dt = dtn; |
245 | retInc = inc; | 245 | retInc = inc; |
246 | } | 246 | } |
247 | inc = mAlarms.next(); | 247 | inc = mAlarms.next(); |
248 | } | 248 | } |
249 | mAlarms.remove( retInc ); | 249 | mAlarms.remove( retInc ); |
250 | return retInc; | 250 | return retInc; |
251 | 251 | ||
252 | } | 252 | } |
253 | void MissedAlarmTextBrowser::setSource(const QString & n) | 253 | void MissedAlarmTextBrowser::setSource(const QString & n) |
254 | { | 254 | { |
255 | if (n.startsWith("event:")) { | 255 | if (n.startsWith("event:")) { |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | emit showIncidence(n.mid(8)); | 257 | emit showIncidence(n.mid(8)); |
258 | #else | 258 | #else |
259 | emit showIncidence(n.mid(6)); | 259 | emit showIncidence(n.mid(6)); |
260 | #endif | 260 | #endif |
261 | return; | 261 | return; |
262 | } else if (n.startsWith("todo:")) { | 262 | } else if (n.startsWith("todo:")) { |
263 | #ifdef DESKTOP_VERSION | 263 | #ifdef DESKTOP_VERSION |
264 | emit showIncidence(n.mid(7)); | 264 | emit showIncidence(n.mid(7)); |
265 | #else | 265 | #else |
266 | emit showIncidence(n.mid(5)); | 266 | emit showIncidence(n.mid(5)); |
267 | #endif | 267 | #endif |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | class KOBeamPrefs : public QDialog | 273 | class KOBeamPrefs : public QDialog |
274 | { | 274 | { |
275 | public: | 275 | public: |
276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 276 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
277 | QDialog( parent, name, true ) | 277 | QDialog( parent, name, true ) |
278 | { | 278 | { |
279 | setCaption( i18n("Beam Options") ); | 279 | setCaption( i18n("Beam Options") ); |
280 | QVBoxLayout* lay = new QVBoxLayout( this ); | 280 | QVBoxLayout* lay = new QVBoxLayout( this ); |
281 | lay->setSpacing( 3 ); | 281 | lay->setSpacing( 3 ); |
282 | lay->setMargin( 3 ); | 282 | lay->setMargin( 3 ); |
283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 283 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
284 | lay->addWidget( format ); | 284 | lay->addWidget( format ); |
285 | format->setExclusive ( true ) ; | 285 | format->setExclusive ( true ) ; |
286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 286 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
287 | lay->addWidget( time ); time->setExclusive ( true ) ; | 287 | lay->addWidget( time ); time->setExclusive ( true ) ; |
288 | vcal = new QRadioButton(" vCalendar ", format ); | 288 | vcal = new QRadioButton(" vCalendar ", format ); |
289 | ical = new QRadioButton(" iCalendar ", format ); | 289 | ical = new QRadioButton(" iCalendar ", format ); |
290 | vcal->setChecked( true ); | 290 | vcal->setChecked( true ); |
291 | tz = new QRadioButton(i18n(" With timezone "), time ); | 291 | tz = new QRadioButton(i18n(" With timezone "), time ); |
292 | local = new QRadioButton(i18n(" Local time "), time ); | 292 | local = new QRadioButton(i18n(" Local time "), time ); |
293 | tz->setChecked( true ); | 293 | tz->setChecked( true ); |
294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 294 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
295 | lay->addWidget( ok ); | 295 | lay->addWidget( ok ); |
296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 296 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
297 | lay->addWidget( cancel ); | 297 | lay->addWidget( cancel ); |
298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 298 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 299 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
300 | resize( 200, 200 ); | 300 | resize( 200, 200 ); |
301 | } | 301 | } |
302 | 302 | ||
303 | bool beamVcal() { return vcal->isChecked(); } | 303 | bool beamVcal() { return vcal->isChecked(); } |
304 | bool beamLocal() { return local->isChecked(); } | 304 | bool beamLocal() { return local->isChecked(); } |
305 | private: | 305 | private: |
306 | QRadioButton* vcal, *ical, *local, *tz; | 306 | QRadioButton* vcal, *ical, *local, *tz; |
307 | }; | 307 | }; |
308 | class KOCatPrefs : public QDialog | 308 | class KOCatPrefs : public QDialog |
309 | { | 309 | { |
310 | public: | 310 | public: |
311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 311 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
312 | QDialog( parent, name, true ) | 312 | QDialog( parent, name, true ) |
313 | { | 313 | { |
314 | setCaption( i18n("Manage new Categories") ); | 314 | setCaption( i18n("Manage new Categories") ); |
315 | QVBoxLayout* lay = new QVBoxLayout( this ); | 315 | QVBoxLayout* lay = new QVBoxLayout( this ); |
316 | lay->setSpacing( 3 ); | 316 | lay->setSpacing( 3 ); |
317 | lay->setMargin( 3 ); | 317 | lay->setMargin( 3 ); |
318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); | 318 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); |
319 | lay->addWidget( lab ); | 319 | lay->addWidget( lab ); |
320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 320 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
321 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
322 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
325 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
327 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 336 | private: |
337 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
347 | { | 347 | { |
348 | 348 | ||
349 | mEventEditor = 0; | 349 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
351 | 351 | ||
352 | init(); | 352 | init(); |
353 | } | 353 | } |
354 | 354 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
360 | { | 360 | { |
361 | 361 | ||
362 | mEventEditor = 0; | 362 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
364 | init(); | 364 | init(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
370 | setFocusPolicy (NoFocus ); | 370 | setFocusPolicy (NoFocus ); |
371 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
372 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
373 | mConflictingEvent = 0; | 373 | mConflictingEvent = 0; |
374 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
375 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
376 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
377 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
378 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
379 | mModified = false; | 379 | mModified = false; |
380 | mReadOnly = false; | 380 | mReadOnly = false; |
381 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
382 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
383 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
384 | 384 | ||
385 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
386 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
387 | 387 | ||
388 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
390 | 390 | ||
391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
392 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
393 | // create the main layout frames. | 393 | // create the main layout frames. |
394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
395 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
396 | 396 | ||
397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
398 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
400 | 400 | ||
401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
402 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
403 | 403 | ||
404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
406 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
408 | 408 | ||
409 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
410 | mResourceView = 0; | 410 | mResourceView = 0; |
411 | #else | 411 | #else |
412 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
414 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
415 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
416 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
417 | } else { | 417 | } else { |
418 | mResourceView = 0; | 418 | mResourceView = 0; |
419 | } | 419 | } |
420 | #endif | 420 | #endif |
421 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
423 | 423 | ||
424 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
425 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
426 | 426 | ||
427 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
428 | #else | 428 | #else |
429 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
430 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
431 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
432 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
433 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
439 | } else { | 439 | } else { |
440 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
446 | } | 446 | } |
447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
448 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
449 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
450 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
452 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
454 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
455 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
456 | #endif | 456 | #endif |
457 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
459 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
460 | #if 0 | 460 | #if 0 |
461 | // FIXME | 461 | // FIXME |
462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
463 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
464 | #endif | 464 | #endif |
465 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
466 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
480 | 480 | ||
481 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
482 | #if 0 | 482 | #if 0 |
483 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
484 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
485 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
486 | 486 | ||
487 | } else { | 487 | } else { |
488 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
489 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
490 | } | 490 | } |
491 | #endif | 491 | #endif |
492 | mFilterView->hide(); | 492 | mFilterView->hide(); |
493 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
494 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
495 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
497 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
498 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
499 | 499 | ||
500 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
501 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
506 | } else { | 506 | } else { |
507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
510 | } | 510 | } |
511 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
512 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
513 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
517 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
518 | 518 | ||
519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
521 | 521 | ||
522 | 522 | ||
523 | 523 | ||
524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
529 | 529 | ||
530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
531 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
532 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
533 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
535 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
537 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
538 | 538 | ||
539 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
540 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
541 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
542 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
548 | #if 0 | 548 | #if 0 |
549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
550 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
551 | #endif | 551 | #endif |
552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
553 | 553 | ||
554 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
555 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
558 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
560 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
562 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
564 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
566 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
569 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
571 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
572 | 572 | ||
573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
576 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
577 | 577 | ||
578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
579 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
581 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
582 | 582 | ||
583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
584 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
589 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
592 | 592 | ||
593 | 593 | ||
594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | void CalendarView::nextConflict( bool all, bool allday ) | 660 | void CalendarView::nextConflict( bool all, bool allday ) |
661 | { | 661 | { |
662 | static bool block = false; | 662 | static bool block = false; |
663 | if ( block ) return; | 663 | if ( block ) return; |
664 | block = true; | 664 | block = true; |
665 | QPtrList<Event> testlist = mCalendar->events(); | 665 | QPtrList<Event> testlist = mCalendar->events(); |
666 | Event * test = testlist.first(); | 666 | Event * test = testlist.first(); |
667 | while ( test ) { | 667 | while ( test ) { |
668 | test->setTagged( false ); | 668 | test->setTagged( false ); |
669 | test = testlist.next(); | 669 | test = testlist.next(); |
670 | } | 670 | } |
671 | QTime st ( 0,0,0); | 671 | QTime st ( 0,0,0); |
672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
673 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 673 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
674 | //qDebug("time %s ", st.toString().latin1()); | 674 | //qDebug("time %s ", st.toString().latin1()); |
675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
676 | QDateTime conflict; | 676 | QDateTime conflict; |
677 | QDateTime retVal; | 677 | QDateTime retVal; |
678 | bool found = false; | 678 | bool found = false; |
679 | Event * cE = 0; | 679 | Event * cE = 0; |
680 | Event * cE2 = 0; | 680 | Event * cE2 = 0; |
681 | QPtrList<Event> testlist2 = testlist; | 681 | QPtrList<Event> testlist2 = testlist; |
682 | test = testlist.first(); | 682 | test = testlist.first(); |
683 | bool skip = false; | 683 | bool skip = false; |
684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
685 | //QTime tm; | 685 | //QTime tm; |
686 | //tm.start(); | 686 | //tm.start(); |
687 | while ( test ) { | 687 | while ( test ) { |
688 | qApp->processEvents(); | 688 | qApp->processEvents(); |
689 | skip = false; | 689 | skip = false; |
690 | if ( !all ) skip = ( allday != test->doesFloat() ); | 690 | if ( !all ) skip = ( allday != test->doesFloat() ); |
691 | if ( !skip ) { | 691 | if ( !skip ) { |
692 | if ( found ) | 692 | if ( found ) |
693 | skip = !test->matchTime( &startDT, &conflict ); | 693 | skip = !test->matchTime( &startDT, &conflict ); |
694 | else | 694 | else |
695 | skip = !test->matchTime( &startDT, 0 ); | 695 | skip = !test->matchTime( &startDT, 0 ); |
696 | } | 696 | } |
697 | if ( !skip ) { | 697 | if ( !skip ) { |
698 | Event * test2 = testlist2.first(); | 698 | Event * test2 = testlist2.first(); |
699 | while ( test2 ) { | 699 | while ( test2 ) { |
700 | skip = test2->isTagged(); | 700 | skip = test2->isTagged(); |
701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); | 701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
702 | if ( !skip ) { | 702 | if ( !skip ) { |
703 | if ( found ) | 703 | if ( found ) |
704 | skip = !test2->matchTime( &startDT, &conflict ); | 704 | skip = !test2->matchTime( &startDT, &conflict ); |
705 | else | 705 | else |
706 | skip = !test2->matchTime( &startDT, 0 ); | 706 | skip = !test2->matchTime( &startDT, 0 ); |
707 | } | 707 | } |
708 | if ( !skip ) { | 708 | if ( !skip ) { |
709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
710 | //qDebug("overlap "); | 710 | //qDebug("overlap "); |
711 | if ( ! found ) { | 711 | if ( ! found ) { |
712 | if ( retVal >= startDT ) { | 712 | if ( retVal >= startDT ) { |
713 | conflict = retVal; | 713 | conflict = retVal; |
714 | cE = test; | 714 | cE = test; |
715 | cE2 = test2; | 715 | cE2 = test2; |
716 | found = true; | 716 | found = true; |
717 | } | 717 | } |
718 | } else { | 718 | } else { |
719 | if ( retVal >= startDT && retVal < conflict ) { | 719 | if ( retVal >= startDT && retVal < conflict ) { |
720 | conflict = retVal; | 720 | conflict = retVal; |
721 | cE = test; | 721 | cE = test; |
722 | cE2 = test2; | 722 | cE2 = test2; |
723 | } | 723 | } |
724 | } | 724 | } |
725 | } | 725 | } |
726 | } | 726 | } |
727 | test2 = testlist2.next(); | 727 | test2 = testlist2.next(); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | test->setTagged( true ); | 730 | test->setTagged( true ); |
731 | test = testlist.next(); | 731 | test = testlist.next(); |
732 | } | 732 | } |
733 | //qDebug("Search time : %d", tm.elapsed()); | 733 | //qDebug("Search time : %d", tm.elapsed()); |
734 | if ( found ) { | 734 | if ( found ) { |
735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
736 | mViewManager->showDayView(); | 736 | mViewManager->showDayView(); |
737 | mNavigator->slotDaySelect( conflict.date() ); | 737 | mNavigator->slotDaySelect( conflict.date() ); |
738 | int hour = conflict.time().hour(); | 738 | int hour = conflict.time().hour(); |
739 | mViewManager->agendaView()->setStartHour( hour ); | 739 | mViewManager->agendaView()->setStartHour( hour ); |
740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
741 | block = false; | 741 | block = false; |
742 | return; | 742 | return; |
743 | } | 743 | } |
744 | 744 | ||
745 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 745 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
746 | //qDebug("No conflict found "); | 746 | //qDebug("No conflict found "); |
747 | block = false; | 747 | block = false; |
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | 750 | ||
751 | void CalendarView::conflictAll() | 751 | void CalendarView::conflictAll() |
752 | { | 752 | { |
753 | nextConflict ( true, true ); | 753 | nextConflict ( true, true ); |
754 | } | 754 | } |
755 | void CalendarView::conflictAllday() | 755 | void CalendarView::conflictAllday() |
756 | { | 756 | { |
757 | nextConflict ( false, true ); | 757 | nextConflict ( false, true ); |
758 | } | 758 | } |
759 | void CalendarView::conflictNotAll() | 759 | void CalendarView::conflictNotAll() |
760 | { | 760 | { |
761 | nextConflict ( false, false ); | 761 | nextConflict ( false, false ); |
762 | } | 762 | } |
763 | 763 | ||
764 | void CalendarView::setCalReadOnly( int id, bool readO ) | 764 | void CalendarView::setCalReadOnly( int id, bool readO ) |
765 | { | 765 | { |
766 | if ( readO ) { | 766 | if ( readO ) { |
767 | emit save(); | 767 | emit save(); |
768 | } | 768 | } |
769 | mCalendar->setReadOnly( id, readO ); | 769 | mCalendar->setReadOnly( id, readO ); |
770 | } | 770 | } |
771 | void CalendarView::setScrollBarStep(int val ) | 771 | void CalendarView::setScrollBarStep(int val ) |
772 | { | 772 | { |
773 | #ifdef DESKTOP_VERSION | 773 | #ifdef DESKTOP_VERSION |
774 | mDateScrollBar->setLineStep ( val ); | 774 | mDateScrollBar->setLineStep ( val ); |
775 | #endif | 775 | #endif |
776 | } | 776 | } |
777 | void CalendarView::scrollBarValue(int val ) | 777 | void CalendarView::scrollBarValue(int val ) |
778 | { | 778 | { |
779 | #ifdef DESKTOP_VERSION | 779 | #ifdef DESKTOP_VERSION |
780 | if ( QApplication::desktop()->width() < 800 ) return; | 780 | if ( QApplication::desktop()->width() < 800 ) return; |
781 | static bool block = false; | 781 | static bool block = false; |
782 | if ( block ) return; | 782 | if ( block ) return; |
783 | block = true; | 783 | block = true; |
784 | int count = mNavigator->selectedDates().count(); | 784 | int count = mNavigator->selectedDates().count(); |
785 | int day = mNavigator->selectedDates().first().dayOfYear(); | 785 | int day = mNavigator->selectedDates().first().dayOfYear(); |
786 | int stepdays = val; | 786 | int stepdays = val; |
787 | if ( mDateScrollBar->lineStep () <= count ) { | 787 | if ( mDateScrollBar->lineStep () <= count ) { |
788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
789 | //qDebug("VAL %d ",val ); | 789 | //qDebug("VAL %d ",val ); |
790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
791 | stepdays = day+stepdays; | 791 | stepdays = day+stepdays; |
792 | if ( stepdays < 0 ) stepdays = 0; | 792 | if ( stepdays < 0 ) stepdays = 0; |
793 | } | 793 | } |
794 | if ( stepdays == day ) { | 794 | if ( stepdays == day ) { |
795 | block = false; | 795 | block = false; |
796 | return; | 796 | return; |
797 | } | 797 | } |
798 | int year = mNavigator->selectedDates().first().year(); | 798 | int year = mNavigator->selectedDates().first().year(); |
799 | QDate d ( year,1,1 ); | 799 | QDate d ( year,1,1 ); |
800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
801 | block = false; | 801 | block = false; |
802 | #endif | 802 | #endif |
803 | 803 | ||
804 | } | 804 | } |
805 | void CalendarView::updateView(const QDate &start, const QDate &end) | 805 | void CalendarView::updateView(const QDate &start, const QDate &end) |
806 | { | 806 | { |
807 | #ifdef DESKTOP_VERSION | 807 | #ifdef DESKTOP_VERSION |
808 | if ( ! mDateScrollBar->draggingSlider () ) { | 808 | if ( ! mDateScrollBar->draggingSlider () ) { |
809 | int dof = start.dayOfYear(); | 809 | int dof = start.dayOfYear(); |
810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
811 | if ( dof != mDateScrollBar->value() ) { | 811 | if ( dof != mDateScrollBar->value() ) { |
812 | mDateScrollBar->blockSignals( true ); | 812 | mDateScrollBar->blockSignals( true ); |
813 | mDateScrollBar->setValue( start.dayOfYear()); | 813 | mDateScrollBar->setValue( start.dayOfYear()); |
814 | mDateScrollBar->blockSignals( false ); | 814 | mDateScrollBar->blockSignals( false ); |
815 | } | 815 | } |
816 | } | 816 | } |
817 | #endif | 817 | #endif |
818 | mTodoList->updateView(); | 818 | mTodoList->updateView(); |
819 | mViewManager->updateView(start, end); | 819 | mViewManager->updateView(start, end); |
820 | //mDateNavigator->updateView(); | 820 | //mDateNavigator->updateView(); |
821 | } | 821 | } |
822 | 822 | ||
823 | 823 | ||
824 | 824 | ||
825 | void CalendarView::checkFiles() | 825 | void CalendarView::checkFiles() |
826 | { | 826 | { |
827 | QString message; | 827 | QString message; |
828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
829 | KopiCalendarFile * cal = calendars.first(); | 829 | KopiCalendarFile * cal = calendars.first(); |
830 | while ( cal ) { | 830 | while ( cal ) { |
831 | if ( cal->mErrorOnLoad ) { | 831 | if ( cal->mErrorOnLoad ) { |
832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
833 | } | 833 | } |
834 | cal = calendars.next(); | 834 | cal = calendars.next(); |
835 | } | 835 | } |
836 | if ( !message.isEmpty() ) { | 836 | if ( !message.isEmpty() ) { |
837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
838 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 838 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
839 | } | 839 | } |
840 | static bool firstTime = true; | 840 | static bool firstTime = true; |
841 | if ( firstTime ) { | 841 | if ( firstTime ) { |
842 | firstTime = false; | 842 | firstTime = false; |
843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
844 | } | 844 | } |
845 | } | 845 | } |
846 | void CalendarView::checkAlarms() | 846 | void CalendarView::checkAlarms() |
847 | { | 847 | { |
848 | KConfig *config = KOGlobals::config(); | 848 | KConfig *config = KOGlobals::config(); |
849 | config->setGroup( "AppRun" ); | 849 | config->setGroup( "AppRun" ); |
850 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 850 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
851 | int daysto = dt.daysTo( QDate::currentDate() ); | 851 | int daysto = dt.daysTo( QDate::currentDate() ); |
852 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 852 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
853 | dt = dt.addDays( days ); | 853 | dt = dt.addDays( days ); |
854 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 854 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
855 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 855 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
856 | //qDebug("KO: Reading program stop %d ", secs); | 856 | //qDebug("KO: Reading program stop %d ", secs); |
857 | //secs -= ( 3600 * 24*3 ); // debug only | 857 | //secs -= ( 3600 * 24*3 ); // debug only |
858 | QDateTime latest = dt.addSecs ( secs ); | 858 | QDateTime latest = dt.addSecs ( secs ); |
859 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 859 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
860 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 860 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
861 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 861 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
862 | QPtrList<Incidence> al; | 862 | QPtrList<Incidence> al; |
863 | Incidence* inL = el.first(); | 863 | Incidence* inL = el.first(); |
864 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 864 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
865 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 865 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
866 | while ( inL ) { | 866 | while ( inL ) { |
867 | bool ok = false; | 867 | bool ok = false; |
868 | int offset = 0; | 868 | int offset = 0; |
869 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 869 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
870 | if ( ok ) { | 870 | if ( ok ) { |
871 | //qDebug("OK %s",next.toString().latin1()); | 871 | //qDebug("OK %s",next.toString().latin1()); |
872 | if ( next < cur ) { | 872 | if ( next < cur ) { |
873 | al.append( inL ); | 873 | al.append( inL ); |
874 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 874 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
875 | } | 875 | } |
876 | } | 876 | } |
877 | inL = el.next(); | 877 | inL = el.next(); |
878 | } | 878 | } |
879 | if ( al.count() ) { | 879 | if ( al.count() ) { |
880 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 880 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
881 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 881 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
882 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 882 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
883 | lay->setSpacing( 0 ); | 883 | lay->setSpacing( 0 ); |
884 | lay->setMargin( 0 ); | 884 | lay->setMargin( 0 ); |
885 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 885 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
886 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 886 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
887 | lay->addWidget( matb ); | 887 | lay->addWidget( matb ); |
888 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 888 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
889 | int wid = 210; | 889 | int wid = 210; |
890 | int x = QApplication::desktop()->width() - wid - 7; | 890 | int x = QApplication::desktop()->width() - wid - 7; |
891 | int y = QApplication::desktop()->height() - wid - 70; | 891 | int y = QApplication::desktop()->height() - wid - 70; |
892 | dia->setGeometry ( x,y,wid,wid); | 892 | dia->setGeometry ( x,y,wid,wid); |
893 | } else { | 893 | } else { |
894 | int si = 220; | 894 | int si = 220; |
895 | if ( QApplication::desktop()->width() > 470 ) | 895 | if ( QApplication::desktop()->width() > 470 ) |
896 | si = 400; | 896 | si = 400; |
897 | dia->resize(si,si/2); | 897 | dia->resize(si,si/2); |
898 | } | 898 | } |
899 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 899 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
900 | dia->show(); | 900 | dia->show(); |
901 | 901 | ||
902 | } | 902 | } |
903 | #if 0 | 903 | #if 0 |
904 | // for creating timetracker test data | 904 | // for creating timetracker test data |
905 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); | 905 | qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); |
906 | Todo * nt; | 906 | Todo * nt; |
907 | mCalendar->close(); | 907 | mCalendar->close(); |
908 | { | 908 | { |
909 | Todo * root1 = new Todo; | 909 | Todo * root1 = new Todo; |
910 | mCalendar->addTodo( root1 ); | 910 | mCalendar->addTodo( root1 ); |
911 | root1->setSummary( "Project_1"); | 911 | root1->setSummary( "Project_1"); |
912 | root1->setPriority( 1 ); | 912 | root1->setPriority( 1 ); |
913 | root1->setDescription( "This is a test description of a root Project" ); | 913 | root1->setDescription( "This is a test description of a root Project" ); |
914 | root1->setPercentComplete( 20 ); | 914 | root1->setPercentComplete( 20 ); |
915 | updateView(); | 915 | updateView(); |
916 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 916 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
917 | QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) ); | 917 | QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) ); |
918 | 918 | ||
919 | nt = new Todo; | 919 | nt = new Todo; |
920 | mCalendar->addTodo( nt ); | 920 | mCalendar->addTodo( nt ); |
921 | nt->setSummary( "Planning_Project_1"); | 921 | nt->setSummary( "Planning_Project_1"); |
922 | nt->setPriority( 1 ); | 922 | nt->setPriority( 1 ); |
923 | nt->setDescription( "This is a test description of Planning_Project_1" ); | 923 | nt->setDescription( "This is a test description of Planning_Project_1" ); |
924 | nt->setPercentComplete( 20 ); | 924 | nt->setPercentComplete( 20 ); |
925 | 925 | ||
926 | 926 | ||
927 | Todo * sub1 = nt; | 927 | Todo * sub1 = nt; |
928 | sub1->setRelatedTo( root1 ); | 928 | sub1->setRelatedTo( root1 ); |
929 | 929 | ||
930 | nt = new Todo; | 930 | nt = new Todo; |
931 | mCalendar->addTodo( nt ); | 931 | mCalendar->addTodo( nt ); |
932 | nt->setSummary( "Planning_Project_1: Lutz"); | 932 | nt->setSummary( "Planning_Project_1: Lutz"); |
933 | nt->setPriority( 1 ); | 933 | nt->setPriority( 1 ); |
934 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 934 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
935 | nt->setPercentComplete( 20 ); | 935 | nt->setPercentComplete( 20 ); |
936 | Todo * workLutz11 = nt; | 936 | Todo * workLutz11 = nt; |
937 | workLutz11->setRelatedTo( sub1 ); | 937 | workLutz11->setRelatedTo( sub1 ); |
938 | 938 | ||
939 | nt = new Todo; | 939 | nt = new Todo; |
940 | mCalendar->addTodo( nt ); | 940 | mCalendar->addTodo( nt ); |
941 | nt->setSummary( "Planning_Project_1: Norbert"); | 941 | nt->setSummary( "Planning_Project_1: Norbert"); |
942 | nt->setPriority( 1 ); | 942 | nt->setPriority( 1 ); |
943 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 943 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
944 | nt->setPercentComplete( 20 ); | 944 | nt->setPercentComplete( 20 ); |
945 | Todo * workNorbert11 = nt; | 945 | Todo * workNorbert11 = nt; |
946 | workNorbert11->setRelatedTo( sub1 ); | 946 | workNorbert11->setRelatedTo( sub1 ); |
947 | 947 | ||
948 | nt = new Todo; | 948 | nt = new Todo; |
949 | mCalendar->addTodo( nt ); | 949 | mCalendar->addTodo( nt ); |
950 | nt->setSummary( "Work on 1"); | 950 | nt->setSummary( "Work on 1"); |
951 | nt->setPriority( 1 ); | 951 | nt->setPriority( 1 ); |
952 | nt->setDescription( "This is a test description of Work Project_1" ); | 952 | nt->setDescription( "This is a test description of Work Project_1" ); |
953 | nt->setPercentComplete( 20 ); | 953 | nt->setPercentComplete( 20 ); |
954 | 954 | ||
955 | Todo * sub2 = nt; | 955 | Todo * sub2 = nt; |
956 | sub2->setRelatedTo( root1 ); | 956 | sub2->setRelatedTo( root1 ); |
957 | 957 | ||
958 | 958 | ||
959 | nt = new Todo; | 959 | nt = new Todo; |
960 | mCalendar->addTodo( nt ); | 960 | mCalendar->addTodo( nt ); |
961 | nt->setSummary( "Work on 1: Lutz"); | 961 | nt->setSummary( "Work on 1: Lutz"); |
962 | nt->setPriority( 1 ); | 962 | nt->setPriority( 1 ); |
963 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 963 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
964 | nt->setPercentComplete( 20 ); | 964 | nt->setPercentComplete( 20 ); |
965 | Todo * workLutz12 = nt; | 965 | Todo * workLutz12 = nt; |
966 | workLutz12->setRelatedTo( sub2 ); | 966 | workLutz12->setRelatedTo( sub2 ); |
967 | 967 | ||
968 | nt = new Todo; | 968 | nt = new Todo; |
969 | mCalendar->addTodo( nt ); | 969 | mCalendar->addTodo( nt ); |
970 | nt->setSummary( "Work on 1: Norbert"); | 970 | nt->setSummary( "Work on 1: Norbert"); |
971 | nt->setPriority( 1 ); | 971 | nt->setPriority( 1 ); |
972 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 972 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
973 | nt->setPercentComplete( 20 ); | 973 | nt->setPercentComplete( 20 ); |
974 | Todo * workNorbert12 = nt; | 974 | Todo * workNorbert12 = nt; |
975 | workNorbert12->setRelatedTo( sub2 ); | 975 | workNorbert12->setRelatedTo( sub2 ); |
976 | 976 | ||
977 | int secLenRunning = 7200; | 977 | int secLenRunning = 7200; |
978 | int secLenPausing = 3600 * 3; | 978 | int secLenPausing = 3600 * 3; |
979 | int dayInterval = 1; | 979 | int dayInterval = 1; |
980 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); | 980 | //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); |
981 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); | 981 | createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); |
982 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); | 982 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); |
983 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); | 983 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); |
984 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); | 984 | createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); |
985 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); | 985 | createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); |
986 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); | 986 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); |
987 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); | 987 | createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); |
988 | 988 | ||
989 | } | 989 | } |
990 | 990 | ||
991 | { | 991 | { |
992 | Todo * root1 = new Todo; | 992 | Todo * root1 = new Todo; |
993 | mCalendar->addTodo( root1 ); | 993 | mCalendar->addTodo( root1 ); |
994 | root1->setSummary( "Project_2"); | 994 | root1->setSummary( "Project_2"); |
995 | root1->setPriority( 1 ); | 995 | root1->setPriority( 1 ); |
996 | root1->setDescription( "This is a test description of a root Project 2" ); | 996 | root1->setDescription( "This is a test description of a root Project 2" ); |
997 | root1->setPercentComplete( 20 ); | 997 | root1->setPercentComplete( 20 ); |
998 | updateView(); | 998 | updateView(); |
999 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); | 999 | QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); |
1000 | QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) ); | 1000 | QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) ); |
1001 | int secLenRunning = 7200; | 1001 | int secLenRunning = 7200; |
1002 | int secLenPausing = 3600 * 3; | 1002 | int secLenPausing = 3600 * 3; |
1003 | int dayInterval = 1; | 1003 | int dayInterval = 1; |
1004 | 1004 | ||
1005 | nt = new Todo; | 1005 | nt = new Todo; |
1006 | mCalendar->addTodo( nt ); | 1006 | mCalendar->addTodo( nt ); |
1007 | nt->setSummary( "Planning_Project_2"); | 1007 | nt->setSummary( "Planning_Project_2"); |
1008 | nt->setPriority( 1 ); | 1008 | nt->setPriority( 1 ); |
1009 | nt->setDescription( "This is a test description of Planning_Project_2" ); | 1009 | nt->setDescription( "This is a test description of Planning_Project_2" ); |
1010 | nt->setPercentComplete( 20 ); | 1010 | nt->setPercentComplete( 20 ); |
1011 | 1011 | ||
1012 | 1012 | ||
1013 | Todo * sub1 = nt; | 1013 | Todo * sub1 = nt; |
1014 | sub1->setRelatedTo( root1 ); | 1014 | sub1->setRelatedTo( root1 ); |
1015 | 1015 | ||
1016 | nt = new Todo; | 1016 | nt = new Todo; |
1017 | mCalendar->addTodo( nt ); | 1017 | mCalendar->addTodo( nt ); |
1018 | nt->setSummary( "Planning_Project_2: Lutz"); | 1018 | nt->setSummary( "Planning_Project_2: Lutz"); |
1019 | nt->setPriority( 1 ); | 1019 | nt->setPriority( 1 ); |
1020 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1020 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1021 | nt->setPercentComplete( 20 ); | 1021 | nt->setPercentComplete( 20 ); |
1022 | Todo * workLutz11 = nt; | 1022 | Todo * workLutz11 = nt; |
1023 | workLutz11->setRelatedTo( sub1 ); | 1023 | workLutz11->setRelatedTo( sub1 ); |
1024 | 1024 | ||
1025 | nt = new Todo; | 1025 | nt = new Todo; |
1026 | mCalendar->addTodo( nt ); | 1026 | mCalendar->addTodo( nt ); |
1027 | nt->setSummary( "Planning_Project_2: Norbert"); | 1027 | nt->setSummary( "Planning_Project_2: Norbert"); |
1028 | nt->setPriority( 1 ); | 1028 | nt->setPriority( 1 ); |
1029 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1029 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1030 | nt->setPercentComplete( 20 ); | 1030 | nt->setPercentComplete( 20 ); |
1031 | Todo * workNorbert11 = nt; | 1031 | Todo * workNorbert11 = nt; |
1032 | workNorbert11->setRelatedTo( sub1 ); | 1032 | workNorbert11->setRelatedTo( sub1 ); |
1033 | 1033 | ||
1034 | nt = new Todo; | 1034 | nt = new Todo; |
1035 | mCalendar->addTodo( nt ); | 1035 | mCalendar->addTodo( nt ); |
1036 | nt->setSummary( "Work on 2"); | 1036 | nt->setSummary( "Work on 2"); |
1037 | nt->setPriority( 1 ); | 1037 | nt->setPriority( 1 ); |
1038 | nt->setDescription( "This is a test description of Work Project_2" ); | 1038 | nt->setDescription( "This is a test description of Work Project_2" ); |
1039 | nt->setPercentComplete( 20 ); | 1039 | nt->setPercentComplete( 20 ); |
1040 | 1040 | ||
1041 | Todo * sub2 = nt; | 1041 | Todo * sub2 = nt; |
1042 | sub2->setRelatedTo( root1 ); | 1042 | sub2->setRelatedTo( root1 ); |
1043 | 1043 | ||
1044 | 1044 | ||
1045 | nt = new Todo; | 1045 | nt = new Todo; |
1046 | mCalendar->addTodo( nt ); | 1046 | mCalendar->addTodo( nt ); |
1047 | nt->setSummary( "Work on 2: Lutz"); | 1047 | nt->setSummary( "Work on 2: Lutz"); |
1048 | nt->setPriority( 1 ); | 1048 | nt->setPriority( 1 ); |
1049 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1049 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1050 | nt->setPercentComplete( 20 ); | 1050 | nt->setPercentComplete( 20 ); |
1051 | Todo * workLutz12 = nt; | 1051 | Todo * workLutz12 = nt; |
1052 | workLutz12->setRelatedTo( sub2 ); | 1052 | workLutz12->setRelatedTo( sub2 ); |
1053 | 1053 | ||
1054 | nt = new Todo; | 1054 | nt = new Todo; |
1055 | mCalendar->addTodo( nt ); | 1055 | mCalendar->addTodo( nt ); |
1056 | nt->setSummary( "Work on 2: Norbert"); | 1056 | nt->setSummary( "Work on 2: Norbert"); |
1057 | nt->setPriority( 1 ); | 1057 | nt->setPriority( 1 ); |
1058 | nt->setDescription( "This todo counts the actual work of a person on a project" ); | 1058 | nt->setDescription( "This todo counts the actual work of a person on a project" ); |
1059 | nt->setPercentComplete( 20 ); | 1059 | nt->setPercentComplete( 20 ); |
1060 | Todo * workNorbert12 = nt; | 1060 | Todo * workNorbert12 = nt; |
1061 | workNorbert12->setRelatedTo( sub2 ); | 1061 | workNorbert12->setRelatedTo( sub2 ); |
1062 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); | 1062 | createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); |
1063 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); | 1063 | createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); |
1064 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); | 1064 | createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); |
1065 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); | 1065 | createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); |
1066 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); | 1066 | createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); |
1067 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); | 1067 | createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); |
1068 | createRunningDate4Todo( workNorbert11, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); | 1068 | createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); |
1069 | } | 1069 | } |
1070 | updateView(); | 1070 | updateView(); |
1071 | #endif | 1071 | #endif |
1072 | |||
1072 | } | 1073 | } |
1073 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) | 1074 | void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) |
1074 | { | 1075 | { |
1075 | static int ccc = 0; | 1076 | static int ccc = 0; |
1076 | ++ccc; | 1077 | ++ccc; |
1077 | QDateTime t_start = start; | 1078 | QDateTime t_start = start; |
1078 | runT->setPriority( 5 ); | 1079 | runT->setPriority( 5 ); |
1079 | runT->setPercentComplete( 0 ); | 1080 | runT->setPercentComplete( 0 ); |
1080 | int count = 0; | 1081 | int count = 0; |
1081 | int prio = 5; | 1082 | int prio = 5; |
1082 | int complete = 0; | 1083 | int complete = 0; |
1083 | while ( t_start < end ) { | 1084 | while ( t_start < end ) { |
1084 | ++count; | 1085 | ++count; |
1085 | if ( count > ccc ) { | 1086 | if ( count > ccc ) { |
1086 | count = 0; | 1087 | count = 0; |
1087 | --prio; | 1088 | --prio; |
1088 | if ( prio == 0 ) prio = 5; | 1089 | if ( prio == 0 ) prio = 5; |
1089 | complete += 20; | 1090 | complete += 20; |
1090 | if ( complete > 100 ) complete = 0; | 1091 | if ( complete > 100 ) complete = 0; |
1091 | runT->setPriority( prio ); | 1092 | runT->setPriority( prio ); |
1092 | runT->setPercentComplete( complete ); | 1093 | runT->setPercentComplete( complete ); |
1093 | } | 1094 | } |
1094 | runT->setRunning( true ); | 1095 | runT->setRunning( true ); |
1095 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); | 1096 | runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); |
1096 | if ( dayInterval ) | 1097 | if ( dayInterval ) |
1097 | t_start = t_start.addDays( dayInterval ); | 1098 | t_start = t_start.addDays( dayInterval ); |
1098 | else { | 1099 | else { |
1099 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); | 1100 | t_start = t_start.addSecs( secLenRunning + secLenPausing ); |
1100 | } | 1101 | } |
1101 | } | 1102 | } |
1102 | } | 1103 | } |
1103 | 1104 | ||
1104 | void CalendarView::showDay( QDate d ) | 1105 | void CalendarView::showDay( QDate d ) |
1105 | { | 1106 | { |
1106 | dateNavigator()->blockSignals( true ); | 1107 | dateNavigator()->blockSignals( true ); |
1107 | dateNavigator()->selectDate( d ); | 1108 | dateNavigator()->selectDate( d ); |
1108 | dateNavigator()->blockSignals( false ); | 1109 | dateNavigator()->blockSignals( false ); |
1109 | mViewManager->showDayView(); | 1110 | mViewManager->showDayView(); |
1110 | //dateNavigator()->selectDate( d ); | 1111 | //dateNavigator()->selectDate( d ); |
1111 | } | 1112 | } |
1112 | void CalendarView::timerAlarm() | 1113 | void CalendarView::timerAlarm() |
1113 | { | 1114 | { |
1114 | //qDebug("CalendarView::timerAlarm() "); | 1115 | //qDebug("CalendarView::timerAlarm() "); |
1115 | computeAlarm(mAlarmNotification ); | 1116 | computeAlarm(mAlarmNotification ); |
1116 | } | 1117 | } |
1117 | 1118 | ||
1118 | void CalendarView::suspendAlarm() | 1119 | void CalendarView::suspendAlarm() |
1119 | { | 1120 | { |
1120 | //qDebug(" CalendarView::suspendAlarm() "); | 1121 | //qDebug(" CalendarView::suspendAlarm() "); |
1121 | computeAlarm(mSuspendAlarmNotification ); | 1122 | computeAlarm(mSuspendAlarmNotification ); |
1122 | 1123 | ||
1123 | } | 1124 | } |
1124 | 1125 | ||
1125 | void CalendarView::startAlarm( QString mess , QString filename) | 1126 | void CalendarView::startAlarm( QString mess , QString filename) |
1126 | { | 1127 | { |
1127 | 1128 | ||
1128 | topLevelWidget()->showNormal(); | 1129 | topLevelWidget()->showNormal(); |
1129 | topLevelWidget()->setActiveWindow(); | 1130 | topLevelWidget()->setActiveWindow(); |
1130 | topLevelWidget()->raise(); | 1131 | topLevelWidget()->raise(); |
1131 | 1132 | ||
1132 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 1133 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
1133 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 1134 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
1134 | 1135 | ||
1135 | } | 1136 | } |
1136 | 1137 | ||
1137 | void CalendarView::checkNextTimerAlarm() | 1138 | void CalendarView::checkNextTimerAlarm() |
1138 | { | 1139 | { |
1139 | mCalendar->checkAlarmForIncidence( 0, true ); | 1140 | mCalendar->checkAlarmForIncidence( 0, true ); |
1140 | } | 1141 | } |
1141 | 1142 | ||
1142 | void CalendarView::computeAlarm( QString msg ) | 1143 | void CalendarView::computeAlarm( QString msg ) |
1143 | { | 1144 | { |
1144 | 1145 | ||
1145 | QString mess = msg; | 1146 | QString mess = msg; |
1146 | QString mAlarmMessage = mess.mid( 9 ); | 1147 | QString mAlarmMessage = mess.mid( 9 ); |
1147 | QString filename = MainWindow::resourcePath(); | 1148 | QString filename = MainWindow::resourcePath(); |
1148 | filename += "koalarm.wav"; | 1149 | filename += "koalarm.wav"; |
1149 | QString tempfilename; | 1150 | QString tempfilename; |
1150 | if ( mess.left( 13 ) == "suspend_alarm") { | 1151 | if ( mess.left( 13 ) == "suspend_alarm") { |
1151 | bool error = false; | 1152 | bool error = false; |
1152 | int len = mess.mid( 13 ).find("+++"); | 1153 | int len = mess.mid( 13 ).find("+++"); |
1153 | if ( len < 2 ) | 1154 | if ( len < 2 ) |
1154 | error = true; | 1155 | error = true; |
1155 | else { | 1156 | else { |
1156 | tempfilename = mess.mid( 13, len ); | 1157 | tempfilename = mess.mid( 13, len ); |
1157 | if ( !QFile::exists( tempfilename ) ) | 1158 | if ( !QFile::exists( tempfilename ) ) |
1158 | error = true; | 1159 | error = true; |
1159 | } | 1160 | } |
1160 | if ( ! error ) { | 1161 | if ( ! error ) { |
1161 | filename = tempfilename; | 1162 | filename = tempfilename; |
1162 | } | 1163 | } |
1163 | mAlarmMessage = mess.mid( 13+len+3 ); | 1164 | mAlarmMessage = mess.mid( 13+len+3 ); |
1164 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 1165 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
1165 | startAlarm( mAlarmMessage, filename); | 1166 | startAlarm( mAlarmMessage, filename); |
1166 | return; | 1167 | return; |
1167 | } | 1168 | } |
1168 | if ( mess.left( 11 ) == "timer_alarm") { | 1169 | if ( mess.left( 11 ) == "timer_alarm") { |
1169 | //mTimerTime = 0; | 1170 | //mTimerTime = 0; |
1170 | startAlarm( mess.mid( 11 ), filename ); | 1171 | startAlarm( mess.mid( 11 ), filename ); |
1171 | return; | 1172 | return; |
1172 | } | 1173 | } |
1173 | if ( mess.left( 10 ) == "proc_alarm") { | 1174 | if ( mess.left( 10 ) == "proc_alarm") { |
1174 | bool error = false; | 1175 | bool error = false; |
1175 | int len = mess.mid( 10 ).find("+++"); | 1176 | int len = mess.mid( 10 ).find("+++"); |
1176 | if ( len < 2 ) | 1177 | if ( len < 2 ) |
1177 | error = true; | 1178 | error = true; |
1178 | else { | 1179 | else { |
1179 | tempfilename = mess.mid( 10, len ); | 1180 | tempfilename = mess.mid( 10, len ); |
1180 | if ( !QFile::exists( tempfilename ) ) | 1181 | if ( !QFile::exists( tempfilename ) ) |
1181 | error = true; | 1182 | error = true; |
1182 | } | 1183 | } |
1183 | if ( error ) { | 1184 | if ( error ) { |
1184 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 1185 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
1185 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 1186 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
1186 | } else { | 1187 | } else { |
1187 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 1188 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
1188 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 1189 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
1189 | #ifndef _WIN32_ | 1190 | #ifndef _WIN32_ |
1190 | if ( vfork () == 0 ) { | 1191 | if ( vfork () == 0 ) { |
1191 | execl ( tempfilename.latin1(), 0 ); | 1192 | execl ( tempfilename.latin1(), 0 ); |
1192 | return; | 1193 | return; |
1193 | } | 1194 | } |
1194 | #else | 1195 | #else |
1195 | QProcess* p = new QProcess(); | 1196 | QProcess* p = new QProcess(); |
1196 | p->addArgument( tempfilename.latin1() ); | 1197 | p->addArgument( tempfilename.latin1() ); |
1197 | p->start(); | 1198 | p->start(); |
1198 | return; | 1199 | return; |
1199 | #endif | 1200 | #endif |
1200 | 1201 | ||
1201 | return; | 1202 | return; |
1202 | } | 1203 | } |
1203 | 1204 | ||
1204 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1205 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1205 | } | 1206 | } |
1206 | if ( mess.left( 11 ) == "audio_alarm") { | 1207 | if ( mess.left( 11 ) == "audio_alarm") { |
1207 | bool error = false; | 1208 | bool error = false; |
1208 | int len = mess.mid( 11 ).find("+++"); | 1209 | int len = mess.mid( 11 ).find("+++"); |
1209 | if ( len < 2 ) | 1210 | if ( len < 2 ) |
1210 | error = true; | 1211 | error = true; |
1211 | else { | 1212 | else { |
1212 | tempfilename = mess.mid( 11, len ); | 1213 | tempfilename = mess.mid( 11, len ); |
1213 | if ( !QFile::exists( tempfilename ) ) | 1214 | if ( !QFile::exists( tempfilename ) ) |
1214 | error = true; | 1215 | error = true; |
1215 | } | 1216 | } |
1216 | if ( ! error ) { | 1217 | if ( ! error ) { |
1217 | filename = tempfilename; | 1218 | filename = tempfilename; |
1218 | } | 1219 | } |
1219 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1220 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1220 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1221 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1221 | } | 1222 | } |
1222 | if ( mess.left( 9 ) == "cal_alarm") { | 1223 | if ( mess.left( 9 ) == "cal_alarm") { |
1223 | mAlarmMessage = mess.mid( 9 ) ; | 1224 | mAlarmMessage = mess.mid( 9 ) ; |
1224 | } | 1225 | } |
1225 | 1226 | ||
1226 | startAlarm( mAlarmMessage, filename ); | 1227 | startAlarm( mAlarmMessage, filename ); |
1227 | 1228 | ||
1228 | 1229 | ||
1229 | } | 1230 | } |
1230 | 1231 | ||
1231 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1232 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1232 | { | 1233 | { |
1233 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1234 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1234 | 1235 | ||
1235 | mSuspendAlarmNotification = noti; | 1236 | mSuspendAlarmNotification = noti; |
1236 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1237 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1237 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1238 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1238 | mSuspendTimer->start( ms , true ); | 1239 | mSuspendTimer->start( ms , true ); |
1239 | 1240 | ||
1240 | } | 1241 | } |
1241 | 1242 | ||
1242 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1243 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1243 | { | 1244 | { |
1244 | mNextAlarmDateTime = qdt; | 1245 | mNextAlarmDateTime = qdt; |
1245 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1246 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1246 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1247 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1247 | #ifndef DESKTOP_VERSION | 1248 | #ifndef DESKTOP_VERSION |
1248 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1249 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1249 | #endif | 1250 | #endif |
1250 | return; | 1251 | return; |
1251 | } | 1252 | } |
1252 | int maxSec; | 1253 | int maxSec; |
1253 | //maxSec = 5; //testing only | 1254 | //maxSec = 5; //testing only |
1254 | maxSec = 86400+3600; // one day+1hour | 1255 | maxSec = 86400+3600; // one day+1hour |
1255 | mAlarmNotification = noti; | 1256 | mAlarmNotification = noti; |
1256 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1257 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1257 | if ( sec > maxSec ) { | 1258 | if ( sec > maxSec ) { |
1258 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1259 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1259 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1260 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1260 | return; | 1261 | return; |
1261 | } else { | 1262 | } else { |
1262 | mRecheckAlarmTimer->stop(); | 1263 | mRecheckAlarmTimer->stop(); |
1263 | } | 1264 | } |
1264 | //qDebug("Alarm timer started with secs: %d ", sec); | 1265 | //qDebug("Alarm timer started with secs: %d ", sec); |
1265 | mAlarmTimer->start( sec *1000 , true ); | 1266 | mAlarmTimer->start( sec *1000 , true ); |
1266 | 1267 | ||
1267 | } | 1268 | } |
1268 | // called by mRecheckAlarmTimer to get next alarm | 1269 | // called by mRecheckAlarmTimer to get next alarm |
1269 | // we need this, because a QTimer has only a max range of 25 days | 1270 | // we need this, because a QTimer has only a max range of 25 days |
1270 | void CalendarView::recheckTimerAlarm() | 1271 | void CalendarView::recheckTimerAlarm() |
1271 | { | 1272 | { |
1272 | mAlarmTimer->stop(); | 1273 | mAlarmTimer->stop(); |
1273 | mRecheckAlarmTimer->stop(); | 1274 | mRecheckAlarmTimer->stop(); |
1274 | mCalendar->checkAlarmForIncidence( 0, true ); | 1275 | mCalendar->checkAlarmForIncidence( 0, true ); |
1275 | } | 1276 | } |
1276 | #ifndef DESKTOP_VERSION | 1277 | #ifndef DESKTOP_VERSION |
1277 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1278 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1278 | #else | 1279 | #else |
1279 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1280 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1280 | #endif | 1281 | #endif |
1281 | { | 1282 | { |
1282 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1283 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1283 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1284 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1284 | #ifndef DESKTOP_VERSION | 1285 | #ifndef DESKTOP_VERSION |
1285 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1286 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1286 | #endif | 1287 | #endif |
1287 | return; | 1288 | return; |
1288 | } | 1289 | } |
1289 | mAlarmTimer->stop(); | 1290 | mAlarmTimer->stop(); |
1290 | } | 1291 | } |
1291 | void CalendarView::selectWeekNum ( int num ) | 1292 | void CalendarView::selectWeekNum ( int num ) |
1292 | { | 1293 | { |
1293 | dateNavigator()->blockSignals( true ); | 1294 | dateNavigator()->blockSignals( true ); |
1294 | dateNavigator()->selectWeek( num ); | 1295 | dateNavigator()->selectWeek( num ); |
1295 | dateNavigator()->blockSignals( false ); | 1296 | dateNavigator()->blockSignals( false ); |
1296 | mViewManager->showWeekView(); | 1297 | mViewManager->showWeekView(); |
1297 | } | 1298 | } |
1298 | KOViewManager *CalendarView::viewManager() | 1299 | KOViewManager *CalendarView::viewManager() |
1299 | { | 1300 | { |
1300 | return mViewManager; | 1301 | return mViewManager; |
1301 | } | 1302 | } |
1302 | 1303 | ||
1303 | KODialogManager *CalendarView::dialogManager() | 1304 | KODialogManager *CalendarView::dialogManager() |
1304 | { | 1305 | { |
1305 | return mDialogManager; | 1306 | return mDialogManager; |
1306 | } | 1307 | } |
1307 | 1308 | ||
1308 | QDate CalendarView::startDate() | 1309 | QDate CalendarView::startDate() |
1309 | { | 1310 | { |
1310 | DateList dates = mNavigator->selectedDates(); | 1311 | DateList dates = mNavigator->selectedDates(); |
1311 | 1312 | ||
1312 | return dates.first(); | 1313 | return dates.first(); |
1313 | } | 1314 | } |
1314 | 1315 | ||
1315 | QDate CalendarView::endDate() | 1316 | QDate CalendarView::endDate() |
1316 | { | 1317 | { |
1317 | DateList dates = mNavigator->selectedDates(); | 1318 | DateList dates = mNavigator->selectedDates(); |
1318 | 1319 | ||
1319 | return dates.last(); | 1320 | return dates.last(); |
1320 | } | 1321 | } |
1321 | 1322 | ||
1322 | 1323 | ||
1323 | void CalendarView::createPrinter() | 1324 | void CalendarView::createPrinter() |
1324 | { | 1325 | { |
1325 | #ifndef KORG_NOPRINTER | 1326 | #ifndef KORG_NOPRINTER |
1326 | if (!mCalPrinter) { | 1327 | if (!mCalPrinter) { |
1327 | mCalPrinter = new CalPrinter(this, mCalendar); | 1328 | mCalPrinter = new CalPrinter(this, mCalendar); |
1328 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1329 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1329 | } | 1330 | } |
1330 | #endif | 1331 | #endif |
1331 | } | 1332 | } |
1332 | 1333 | ||
1333 | 1334 | ||
1334 | //KOPrefs::instance()->mWriteBackFile | 1335 | //KOPrefs::instance()->mWriteBackFile |
1335 | //KOPrefs::instance()->mWriteBackExistingOnly | 1336 | //KOPrefs::instance()->mWriteBackExistingOnly |
1336 | 1337 | ||
1337 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1338 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1338 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1339 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1339 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1340 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1340 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1341 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1341 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1342 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1342 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1343 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1343 | 1344 | ||
1344 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1345 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1345 | { | 1346 | { |
1346 | 1347 | ||
1347 | // 0 equal | 1348 | // 0 equal |
1348 | // 1 take local | 1349 | // 1 take local |
1349 | // 2 take remote | 1350 | // 2 take remote |
1350 | // 3 cancel | 1351 | // 3 cancel |
1351 | QDateTime lastSync = mLastCalendarSync; | 1352 | QDateTime lastSync = mLastCalendarSync; |
1352 | QDateTime localMod = local->lastModified(); | 1353 | QDateTime localMod = local->lastModified(); |
1353 | QDateTime remoteMod = remote->lastModified(); | 1354 | QDateTime remoteMod = remote->lastModified(); |
1354 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1355 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1355 | bool remCh, locCh; | 1356 | bool remCh, locCh; |
1356 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1357 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1357 | //if ( remCh ) | 1358 | //if ( remCh ) |
1358 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1359 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1359 | locCh = ( localMod > mLastCalendarSync ); | 1360 | locCh = ( localMod > mLastCalendarSync ); |
1360 | if ( !remCh && ! locCh ) { | 1361 | if ( !remCh && ! locCh ) { |
1361 | //qDebug("both not changed "); | 1362 | //qDebug("both not changed "); |
1362 | lastSync = localMod.addDays(1); | 1363 | lastSync = localMod.addDays(1); |
1363 | if ( mode <= SYNC_PREF_ASK ) | 1364 | if ( mode <= SYNC_PREF_ASK ) |
1364 | return 0; | 1365 | return 0; |
1365 | } else { | 1366 | } else { |
1366 | if ( locCh ) { | 1367 | if ( locCh ) { |
1367 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1368 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1368 | lastSync = localMod.addDays( -1 ); | 1369 | lastSync = localMod.addDays( -1 ); |
1369 | if ( !remCh ) | 1370 | if ( !remCh ) |
1370 | remoteMod = ( lastSync.addDays( -1 ) ); | 1371 | remoteMod = ( lastSync.addDays( -1 ) ); |
1371 | } else { | 1372 | } else { |
1372 | //qDebug(" not loc changed "); | 1373 | //qDebug(" not loc changed "); |
1373 | lastSync = localMod.addDays( 1 ); | 1374 | lastSync = localMod.addDays( 1 ); |
1374 | if ( remCh ) | 1375 | if ( remCh ) |
1375 | remoteMod =( lastSync.addDays( 1 ) ); | 1376 | remoteMod =( lastSync.addDays( 1 ) ); |
1376 | 1377 | ||
1377 | } | 1378 | } |
1378 | } | 1379 | } |
1379 | full = true; | 1380 | full = true; |
1380 | if ( mode < SYNC_PREF_ASK ) | 1381 | if ( mode < SYNC_PREF_ASK ) |
1381 | mode = SYNC_PREF_ASK; | 1382 | mode = SYNC_PREF_ASK; |
1382 | } else { | 1383 | } else { |
1383 | if ( localMod == remoteMod ) | 1384 | if ( localMod == remoteMod ) |
1384 | // if ( local->revision() == remote->revision() ) | 1385 | // if ( local->revision() == remote->revision() ) |
1385 | return 0; | 1386 | return 0; |
1386 | 1387 | ||
1387 | } | 1388 | } |
1388 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1389 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1389 | 1390 | ||
1390 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1391 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1391 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1392 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1392 | //full = true; //debug only | 1393 | //full = true; //debug only |
1393 | if ( full ) { | 1394 | if ( full ) { |
1394 | bool equ = false; | 1395 | bool equ = false; |
1395 | if ( local->typeID() == eventID ) { | 1396 | if ( local->typeID() == eventID ) { |
1396 | equ = (*((Event*) local) == *((Event*) remote)); | 1397 | equ = (*((Event*) local) == *((Event*) remote)); |
1397 | } | 1398 | } |
1398 | else if ( local->typeID() == todoID ) | 1399 | else if ( local->typeID() == todoID ) |
1399 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1400 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1400 | else if ( local->typeID() == journalID ) | 1401 | else if ( local->typeID() == journalID ) |
1401 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1402 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1402 | if ( equ ) { | 1403 | if ( equ ) { |
1403 | //qDebug("equal "); | 1404 | //qDebug("equal "); |
1404 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1405 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1405 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1406 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1406 | } | 1407 | } |
1407 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1408 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1408 | return 0; | 1409 | return 0; |
1409 | 1410 | ||
1410 | }//else //debug only | 1411 | }//else //debug only |
1411 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1412 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1412 | } | 1413 | } |
1413 | int result; | 1414 | int result; |
1414 | bool localIsNew; | 1415 | bool localIsNew; |
1415 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 1416 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
1416 | 1417 | ||
1417 | 1418 | ||
1418 | // ************************************************ | 1419 | // ************************************************ |
1419 | // ************************************************ | 1420 | // ************************************************ |
1420 | // ************************************************ | 1421 | // ************************************************ |
1421 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1422 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1422 | // BUT remoteMod != localMod | 1423 | // BUT remoteMod != localMod |
1423 | 1424 | ||
1424 | 1425 | ||
1425 | if ( full && mode < SYNC_PREF_NEWEST ) | 1426 | if ( full && mode < SYNC_PREF_NEWEST ) |
1426 | mode = SYNC_PREF_ASK; | 1427 | mode = SYNC_PREF_ASK; |
1427 | 1428 | ||
1428 | switch( mode ) { | 1429 | switch( mode ) { |
1429 | case SYNC_PREF_LOCAL: | 1430 | case SYNC_PREF_LOCAL: |
1430 | if ( lastSync > remoteMod ) | 1431 | if ( lastSync > remoteMod ) |
1431 | return 1; | 1432 | return 1; |
1432 | if ( lastSync > localMod ) | 1433 | if ( lastSync > localMod ) |
1433 | return 2; | 1434 | return 2; |
1434 | return 1; | 1435 | return 1; |
1435 | break; | 1436 | break; |
1436 | case SYNC_PREF_REMOTE: | 1437 | case SYNC_PREF_REMOTE: |
1437 | if ( lastSync > localMod ) | 1438 | if ( lastSync > localMod ) |
1438 | return 2; | 1439 | return 2; |
1439 | if ( lastSync > remoteMod ) | 1440 | if ( lastSync > remoteMod ) |
1440 | return 1; | 1441 | return 1; |
1441 | return 2; | 1442 | return 2; |
1442 | break; | 1443 | break; |
1443 | case SYNC_PREF_NEWEST: | 1444 | case SYNC_PREF_NEWEST: |
1444 | if ( localMod >= remoteMod ) | 1445 | if ( localMod >= remoteMod ) |
1445 | return 1; | 1446 | return 1; |
1446 | else | 1447 | else |
1447 | return 2; | 1448 | return 2; |
1448 | break; | 1449 | break; |
1449 | case SYNC_PREF_ASK: | 1450 | case SYNC_PREF_ASK: |
1450 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1451 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1451 | if ( lastSync > remoteMod && lastSync > localMod) | 1452 | if ( lastSync > remoteMod && lastSync > localMod) |
1452 | return 0; | 1453 | return 0; |
1453 | if ( lastSync > remoteMod ) | 1454 | if ( lastSync > remoteMod ) |
1454 | return 1; | 1455 | return 1; |
1455 | if ( lastSync > localMod ) | 1456 | if ( lastSync > localMod ) |
1456 | return 2; | 1457 | return 2; |
1457 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1458 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1458 | localIsNew = localMod >= remoteMod; | 1459 | localIsNew = localMod >= remoteMod; |
1459 | if ( localIsNew ) | 1460 | if ( localIsNew ) |
1460 | getEventViewerDialog()->setColorMode( 1 ); | 1461 | getEventViewerDialog()->setColorMode( 1 ); |
1461 | else | 1462 | else |
1462 | getEventViewerDialog()->setColorMode( 2 ); | 1463 | getEventViewerDialog()->setColorMode( 2 ); |
1463 | getEventViewerDialog()->setIncidence(local); | 1464 | getEventViewerDialog()->setIncidence(local); |
1464 | if ( localIsNew ) | 1465 | if ( localIsNew ) |
1465 | getEventViewerDialog()->setColorMode( 2 ); | 1466 | getEventViewerDialog()->setColorMode( 2 ); |
1466 | else | 1467 | else |
1467 | getEventViewerDialog()->setColorMode( 1 ); | 1468 | getEventViewerDialog()->setColorMode( 1 ); |
1468 | getEventViewerDialog()->addIncidence(remote); | 1469 | getEventViewerDialog()->addIncidence(remote); |
1469 | getEventViewerDialog()->setColorMode( 0 ); | 1470 | getEventViewerDialog()->setColorMode( 0 ); |
1470 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1471 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1471 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1472 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1472 | getEventViewerDialog()->showMe(); | 1473 | getEventViewerDialog()->showMe(); |
1473 | result = getEventViewerDialog()->executeS( localIsNew ); | 1474 | result = getEventViewerDialog()->executeS( localIsNew ); |
1474 | return result; | 1475 | return result; |
1475 | 1476 | ||
1476 | break; | 1477 | break; |
1477 | case SYNC_PREF_FORCE_LOCAL: | 1478 | case SYNC_PREF_FORCE_LOCAL: |
1478 | return 1; | 1479 | return 1; |
1479 | break; | 1480 | break; |
1480 | case SYNC_PREF_FORCE_REMOTE: | 1481 | case SYNC_PREF_FORCE_REMOTE: |
1481 | return 2; | 1482 | return 2; |
1482 | break; | 1483 | break; |
1483 | 1484 | ||
1484 | default: | 1485 | default: |
1485 | // SYNC_PREF_TAKE_BOTH not implemented | 1486 | // SYNC_PREF_TAKE_BOTH not implemented |
1486 | break; | 1487 | break; |
1487 | } | 1488 | } |
1488 | return 0; | 1489 | return 0; |
1489 | } | 1490 | } |
1490 | Event* CalendarView::getLastSyncEvent() | 1491 | Event* CalendarView::getLastSyncEvent() |
1491 | { | 1492 | { |
1492 | Event* lse; | 1493 | Event* lse; |
1493 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1494 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1494 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1495 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1495 | if (!lse) { | 1496 | if (!lse) { |
1496 | lse = new Event(); | 1497 | lse = new Event(); |
1497 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1498 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1498 | QString sum = ""; | 1499 | QString sum = ""; |
1499 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1500 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1500 | sum = "E: "; | 1501 | sum = "E: "; |
1501 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1502 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1502 | lse->setDtStart( mLastCalendarSync ); | 1503 | lse->setDtStart( mLastCalendarSync ); |
1503 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1504 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1504 | lse->setCategories( i18n("SyncEvent") ); | 1505 | lse->setCategories( i18n("SyncEvent") ); |
1505 | lse->setReadOnly( true ); | 1506 | lse->setReadOnly( true ); |
1506 | mCalendar->addEvent( lse ); | 1507 | mCalendar->addEvent( lse ); |
1507 | } | 1508 | } |
1508 | 1509 | ||
1509 | return lse; | 1510 | return lse; |
1510 | 1511 | ||
1511 | } | 1512 | } |
1512 | 1513 | ||
1513 | // we check, if the to delete event has a id for a profile | 1514 | // we check, if the to delete event has a id for a profile |
1514 | // if yes, we set this id in the profile to delete | 1515 | // if yes, we set this id in the profile to delete |
1515 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1516 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1516 | { | 1517 | { |
1517 | if ( lastSync.count() == 0 ) { | 1518 | if ( lastSync.count() == 0 ) { |
1518 | //qDebug(" lastSync.count() == 0"); | 1519 | //qDebug(" lastSync.count() == 0"); |
1519 | return; | 1520 | return; |
1520 | } | 1521 | } |
1521 | if ( toDelete->typeID() == journalID ) | 1522 | if ( toDelete->typeID() == journalID ) |
1522 | return; | 1523 | return; |
1523 | 1524 | ||
1524 | Event* eve = lastSync.first(); | 1525 | Event* eve = lastSync.first(); |
1525 | 1526 | ||
1526 | while ( eve ) { | 1527 | while ( eve ) { |
1527 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1528 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1528 | if ( !id.isEmpty() ) { | 1529 | if ( !id.isEmpty() ) { |
1529 | QString des = eve->description(); | 1530 | QString des = eve->description(); |
1530 | QString pref = "e"; | 1531 | QString pref = "e"; |
1531 | if ( toDelete->typeID() == todoID ) | 1532 | if ( toDelete->typeID() == todoID ) |
1532 | pref = "t"; | 1533 | pref = "t"; |
1533 | des += pref+ id + ","; | 1534 | des += pref+ id + ","; |
1534 | eve->setReadOnly( false ); | 1535 | eve->setReadOnly( false ); |
1535 | eve->setDescription( des ); | 1536 | eve->setDescription( des ); |
1536 | //qDebug("setdes %s ", des.latin1()); | 1537 | //qDebug("setdes %s ", des.latin1()); |
1537 | eve->setReadOnly( true ); | 1538 | eve->setReadOnly( true ); |
1538 | } | 1539 | } |
1539 | eve = lastSync.next(); | 1540 | eve = lastSync.next(); |
1540 | } | 1541 | } |
1541 | 1542 | ||
1542 | } | 1543 | } |
1543 | void CalendarView::checkExternalId( Incidence * inc ) | 1544 | void CalendarView::checkExternalId( Incidence * inc ) |
1544 | { | 1545 | { |
1545 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1546 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1546 | checkExternSyncEvent( lastSync, inc ); | 1547 | checkExternSyncEvent( lastSync, inc ); |
1547 | 1548 | ||
1548 | } | 1549 | } |
1549 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1550 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1550 | { | 1551 | { |
1551 | bool syncOK = true; | 1552 | bool syncOK = true; |
1552 | int addedEvent = 0; | 1553 | int addedEvent = 0; |
1553 | int addedEventR = 0; | 1554 | int addedEventR = 0; |
1554 | int deletedEventR = 0; | 1555 | int deletedEventR = 0; |
1555 | int deletedEventL = 0; | 1556 | int deletedEventL = 0; |
1556 | int changedLocal = 0; | 1557 | int changedLocal = 0; |
1557 | int changedRemote = 0; | 1558 | int changedRemote = 0; |
1558 | int filteredIN = 0; | 1559 | int filteredIN = 0; |
1559 | int filteredOUT = 0; | 1560 | int filteredOUT = 0; |
1560 | //QPtrList<Event> el = local->rawEvents(); | 1561 | //QPtrList<Event> el = local->rawEvents(); |
1561 | Event* eventR; | 1562 | Event* eventR; |
1562 | QString uid; | 1563 | QString uid; |
1563 | int take; | 1564 | int take; |
1564 | Event* eventRSync; | 1565 | Event* eventRSync; |
1565 | Event* eventLSync; | 1566 | Event* eventLSync; |
1566 | clearAllViews(); | 1567 | clearAllViews(); |
1567 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1568 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1568 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1569 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1569 | bool fullDateRange = false; | 1570 | bool fullDateRange = false; |
1570 | local->resetTempSyncStat(); | 1571 | local->resetTempSyncStat(); |
1571 | mLastCalendarSync = QDateTime::currentDateTime(); | 1572 | mLastCalendarSync = QDateTime::currentDateTime(); |
1572 | if ( mSyncManager->syncWithDesktop() ) { | 1573 | if ( mSyncManager->syncWithDesktop() ) { |
1573 | remote->resetPilotStat(1); | 1574 | remote->resetPilotStat(1); |
1574 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1575 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1575 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1576 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1576 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1577 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1577 | } else { | 1578 | } else { |
1578 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1579 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1579 | } | 1580 | } |
1580 | } | 1581 | } |
1581 | QDateTime modifiedCalendar = mLastCalendarSync; | 1582 | QDateTime modifiedCalendar = mLastCalendarSync; |
1582 | eventLSync = getLastSyncEvent(); | 1583 | eventLSync = getLastSyncEvent(); |
1583 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1584 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1584 | if ( eventR ) { | 1585 | if ( eventR ) { |
1585 | qDebug("last-syncEvent on remote found "); | 1586 | qDebug("last-syncEvent on remote found "); |
1586 | eventRSync = (Event*) eventR->clone(); | 1587 | eventRSync = (Event*) eventR->clone(); |
1587 | remote->deleteEvent(eventR ); | 1588 | remote->deleteEvent(eventR ); |
1588 | 1589 | ||
1589 | } else { | 1590 | } else { |
1590 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1591 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1591 | eventRSync = (Event*)eventLSync->clone(); | 1592 | eventRSync = (Event*)eventLSync->clone(); |
1592 | } else { | 1593 | } else { |
1593 | fullDateRange = true; | 1594 | fullDateRange = true; |
1594 | eventRSync = new Event(); | 1595 | eventRSync = new Event(); |
1595 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1596 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1596 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1597 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1597 | eventRSync->setDtStart( mLastCalendarSync ); | 1598 | eventRSync->setDtStart( mLastCalendarSync ); |
1598 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1599 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1599 | eventRSync->setCategories( i18n("SyncEvent") ); | 1600 | eventRSync->setCategories( i18n("SyncEvent") ); |
1600 | } | 1601 | } |
1601 | } | 1602 | } |
1602 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1603 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1603 | fullDateRange = true; | 1604 | fullDateRange = true; |
1604 | 1605 | ||
1605 | if ( ! fullDateRange ) { | 1606 | if ( ! fullDateRange ) { |
1606 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1607 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1607 | 1608 | ||
1608 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1609 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1609 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1610 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1610 | fullDateRange = true; | 1611 | fullDateRange = true; |
1611 | } | 1612 | } |
1612 | } | 1613 | } |
1613 | if ( mSyncManager->syncWithDesktop() ) { | 1614 | if ( mSyncManager->syncWithDesktop() ) { |
1614 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1615 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1615 | } | 1616 | } |
1616 | if ( fullDateRange ) | 1617 | if ( fullDateRange ) |
1617 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1618 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1618 | else | 1619 | else |
1619 | mLastCalendarSync = eventLSync->dtStart(); | 1620 | mLastCalendarSync = eventLSync->dtStart(); |
1620 | // for resyncing if own file has changed | 1621 | // for resyncing if own file has changed |
1621 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1622 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1622 | mLastCalendarSync = loadedFileVersion; | 1623 | mLastCalendarSync = loadedFileVersion; |
1623 | //qDebug("setting mLastCalendarSync "); | 1624 | //qDebug("setting mLastCalendarSync "); |
1624 | } | 1625 | } |
1625 | //qDebug("*************************** "); | 1626 | //qDebug("*************************** "); |
1626 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1627 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1627 | QPtrList<Incidence> er = remote->rawIncidences(); | 1628 | QPtrList<Incidence> er = remote->rawIncidences(); |
1628 | Incidence* inR = er.first(); | 1629 | Incidence* inR = er.first(); |
1629 | Incidence* inL; | 1630 | Incidence* inL; |
1630 | QProgressBar bar( er.count(),0 ); | 1631 | QProgressBar bar( er.count(),0 ); |
1631 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1632 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1632 | 1633 | ||
1633 | // ************** setting up filter ************* | 1634 | // ************** setting up filter ************* |
1634 | CalFilter *filterIN = 0; | 1635 | CalFilter *filterIN = 0; |
1635 | CalFilter *filterOUT = 0; | 1636 | CalFilter *filterOUT = 0; |
1636 | CalFilter *filter = mFilters.first(); | 1637 | CalFilter *filter = mFilters.first(); |
1637 | while(filter) { | 1638 | while(filter) { |
1638 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1639 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1639 | filterIN = filter; | 1640 | filterIN = filter; |
1640 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1641 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1641 | filterOUT = filter; | 1642 | filterOUT = filter; |
1642 | filter = mFilters.next(); | 1643 | filter = mFilters.next(); |
1643 | } | 1644 | } |
1644 | int w = 300; | 1645 | int w = 300; |
1645 | if ( QApplication::desktop()->width() < 320 ) | 1646 | if ( QApplication::desktop()->width() < 320 ) |
1646 | w = 220; | 1647 | w = 220; |
1647 | int h = bar.sizeHint().height() ; | 1648 | int h = bar.sizeHint().height() ; |
1648 | int dw = QApplication::desktop()->width(); | 1649 | int dw = QApplication::desktop()->width(); |
1649 | int dh = QApplication::desktop()->height(); | 1650 | int dh = QApplication::desktop()->height(); |
1650 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1651 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1651 | bar.show(); | 1652 | bar.show(); |
1652 | int modulo = (er.count()/10)+1; | 1653 | int modulo = (er.count()/10)+1; |
1653 | int incCounter = 0; | 1654 | int incCounter = 0; |
1654 | while ( inR ) { | 1655 | while ( inR ) { |
1655 | if ( ! bar.isVisible() ) | 1656 | if ( ! bar.isVisible() ) |
1656 | return false; | 1657 | return false; |
1657 | if ( incCounter % modulo == 0 ) | 1658 | if ( incCounter % modulo == 0 ) |
1658 | bar.setProgress( incCounter ); | 1659 | bar.setProgress( incCounter ); |
1659 | ++incCounter; | 1660 | ++incCounter; |
1660 | uid = inR->uid(); | 1661 | uid = inR->uid(); |
1661 | bool skipIncidence = false; | 1662 | bool skipIncidence = false; |
1662 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1663 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1663 | skipIncidence = true; | 1664 | skipIncidence = true; |
1664 | QString idS; | 1665 | QString idS; |
1665 | qApp->processEvents(); | 1666 | qApp->processEvents(); |
1666 | if ( !skipIncidence ) { | 1667 | if ( !skipIncidence ) { |
1667 | inL = local->incidenceForUid( uid , false ); | 1668 | inL = local->incidenceForUid( uid , false ); |
1668 | if ( inL ) { // maybe conflict - same uid in both calendars | 1669 | if ( inL ) { // maybe conflict - same uid in both calendars |
1669 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1670 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1670 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1671 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1671 | if ( take == 3 ) | 1672 | if ( take == 3 ) |
1672 | return false; | 1673 | return false; |
1673 | if ( take == 1 ) {// take local ********************** | 1674 | if ( take == 1 ) {// take local ********************** |
1674 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1675 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1676 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1676 | else | 1677 | else |
1677 | idS = inR->IDStr(); | 1678 | idS = inR->IDStr(); |
1678 | int calID = inR->calID(); | 1679 | int calID = inR->calID(); |
1679 | remote->deleteIncidence( inR ); | 1680 | remote->deleteIncidence( inR ); |
1680 | inR = inL->clone(); | 1681 | inR = inL->clone(); |
1681 | inR->setCalID( calID ); | 1682 | inR->setCalID( calID ); |
1682 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1683 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1683 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1684 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1684 | inR->setIDStr( idS ); | 1685 | inR->setIDStr( idS ); |
1685 | remote->addIncidence( inR ); | 1686 | remote->addIncidence( inR ); |
1686 | if ( mSyncManager->syncWithDesktop() ) | 1687 | if ( mSyncManager->syncWithDesktop() ) |
1687 | inR->setPilotId( 2 ); | 1688 | inR->setPilotId( 2 ); |
1688 | ++changedRemote; | 1689 | ++changedRemote; |
1689 | } else {// take remote ********************** | 1690 | } else {// take remote ********************** |
1690 | if ( !inL->isReadOnly() ) { | 1691 | if ( !inL->isReadOnly() ) { |
1691 | idS = inL->IDStr(); | 1692 | idS = inL->IDStr(); |
1692 | int pid = inL->pilotId(); | 1693 | int pid = inL->pilotId(); |
1693 | int calID = inL->calID(); | 1694 | int calID = inL->calID(); |
1694 | local->deleteIncidence( inL ); | 1695 | local->deleteIncidence( inL ); |
1695 | inL = inR->clone(); | 1696 | inL = inR->clone(); |
1696 | inL->setCalID( calID ); | 1697 | inL->setCalID( calID ); |
1697 | if ( mSyncManager->syncWithDesktop() ) | 1698 | if ( mSyncManager->syncWithDesktop() ) |
1698 | inL->setPilotId( pid ); | 1699 | inL->setPilotId( pid ); |
1699 | inL->setIDStr( idS ); | 1700 | inL->setIDStr( idS ); |
1700 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1701 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1701 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1702 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1702 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1703 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1703 | } | 1704 | } |
1704 | local->addIncidence( inL ); | 1705 | local->addIncidence( inL ); |
1705 | ++changedLocal; | 1706 | ++changedLocal; |
1706 | } | 1707 | } |
1707 | } | 1708 | } |
1708 | } | 1709 | } |
1709 | } else { // no conflict ********** add or delete remote | 1710 | } else { // no conflict ********** add or delete remote |
1710 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1711 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1711 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1712 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1712 | QString des = eventLSync->description(); | 1713 | QString des = eventLSync->description(); |
1713 | QString pref = "e"; | 1714 | QString pref = "e"; |
1714 | if ( inR->typeID() == todoID ) | 1715 | if ( inR->typeID() == todoID ) |
1715 | pref = "t"; | 1716 | pref = "t"; |
1716 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1717 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1717 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1718 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1718 | //remote->deleteIncidence( inR ); | 1719 | //remote->deleteIncidence( inR ); |
1719 | ++deletedEventR; | 1720 | ++deletedEventR; |
1720 | } else { | 1721 | } else { |
1721 | inR->setLastModified( modifiedCalendar ); | 1722 | inR->setLastModified( modifiedCalendar ); |
1722 | inL = inR->clone(); | 1723 | inL = inR->clone(); |
1723 | inL->setIDStr( ":" ); | 1724 | inL->setIDStr( ":" ); |
1724 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1725 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1725 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1726 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1726 | 1727 | ||
1727 | inL->setCalID( 0 );// add to default cal | 1728 | inL->setCalID( 0 );// add to default cal |
1728 | local->addIncidence( inL ); | 1729 | local->addIncidence( inL ); |
1729 | ++addedEvent; | 1730 | ++addedEvent; |
1730 | 1731 | ||
1731 | } | 1732 | } |
1732 | } else { | 1733 | } else { |
1733 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1734 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1734 | inR->setLastModified( modifiedCalendar ); | 1735 | inR->setLastModified( modifiedCalendar ); |
1735 | inL = inR->clone(); | 1736 | inL = inR->clone(); |
1736 | inL->setIDStr( ":" ); | 1737 | inL->setIDStr( ":" ); |
1737 | inL->setCalID( 0 );// add to default cal | 1738 | inL->setCalID( 0 );// add to default cal |
1738 | local->addIncidence( inL ); | 1739 | local->addIncidence( inL ); |
1739 | ++addedEvent; | 1740 | ++addedEvent; |
1740 | 1741 | ||
1741 | } else { | 1742 | } else { |
1742 | checkExternSyncEvent(eventRSyncSharp, inR); | 1743 | checkExternSyncEvent(eventRSyncSharp, inR); |
1743 | remote->deleteIncidence( inR ); | 1744 | remote->deleteIncidence( inR ); |
1744 | ++deletedEventR; | 1745 | ++deletedEventR; |
1745 | } | 1746 | } |
1746 | } | 1747 | } |
1747 | } else { | 1748 | } else { |
1748 | ++filteredIN; | 1749 | ++filteredIN; |
1749 | } | 1750 | } |
1750 | } | 1751 | } |
1751 | } | 1752 | } |
1752 | inR = er.next(); | 1753 | inR = er.next(); |
1753 | } | 1754 | } |
1754 | QPtrList<Incidence> el = local->rawIncidences(); | 1755 | QPtrList<Incidence> el = local->rawIncidences(); |
1755 | inL = el.first(); | 1756 | inL = el.first(); |
1756 | modulo = (el.count()/10)+1; | 1757 | modulo = (el.count()/10)+1; |
1757 | bar.setCaption (i18n("Add / remove events") ); | 1758 | bar.setCaption (i18n("Add / remove events") ); |
1758 | bar.setTotalSteps ( el.count() ) ; | 1759 | bar.setTotalSteps ( el.count() ) ; |
1759 | bar.show(); | 1760 | bar.show(); |
1760 | incCounter = 0; | 1761 | incCounter = 0; |
1761 | 1762 | ||
1762 | while ( inL ) { | 1763 | while ( inL ) { |
1763 | 1764 | ||
1764 | qApp->processEvents(); | 1765 | qApp->processEvents(); |
1765 | if ( ! bar.isVisible() ) | 1766 | if ( ! bar.isVisible() ) |
1766 | return false; | 1767 | return false; |
1767 | if ( incCounter % modulo == 0 ) | 1768 | if ( incCounter % modulo == 0 ) |
1768 | bar.setProgress( incCounter ); | 1769 | bar.setProgress( incCounter ); |
1769 | ++incCounter; | 1770 | ++incCounter; |
1770 | uid = inL->uid(); | 1771 | uid = inL->uid(); |
1771 | bool skipIncidence = false; | 1772 | bool skipIncidence = false; |
1772 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1773 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1773 | skipIncidence = true; | 1774 | skipIncidence = true; |
1774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1775 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1775 | skipIncidence = true; | 1776 | skipIncidence = true; |
1776 | if ( !skipIncidence ) { | 1777 | if ( !skipIncidence ) { |
1777 | inR = remote->incidenceForUid( uid , true ); | 1778 | inR = remote->incidenceForUid( uid , true ); |
1778 | if ( ! inR ) { | 1779 | if ( ! inR ) { |
1779 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1780 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1780 | // no conflict ********** add or delete local | 1781 | // no conflict ********** add or delete local |
1781 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1782 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1782 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1783 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1783 | checkExternSyncEvent(eventLSyncSharp, inL); | 1784 | checkExternSyncEvent(eventLSyncSharp, inL); |
1784 | local->deleteIncidence( inL ); | 1785 | local->deleteIncidence( inL ); |
1785 | ++deletedEventL; | 1786 | ++deletedEventL; |
1786 | } else { | 1787 | } else { |
1787 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1788 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1788 | inL->removeID(mCurrentSyncDevice ); | 1789 | inL->removeID(mCurrentSyncDevice ); |
1789 | ++addedEventR; | 1790 | ++addedEventR; |
1790 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1791 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1791 | inL->setLastModified( modifiedCalendar ); | 1792 | inL->setLastModified( modifiedCalendar ); |
1792 | inR = inL->clone(); | 1793 | inR = inL->clone(); |
1793 | inR->setIDStr( ":" ); | 1794 | inR->setIDStr( ":" ); |
1794 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1795 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1795 | inR->setCalID( 0 );// add to default cal | 1796 | inR->setCalID( 0 );// add to default cal |
1796 | remote->addIncidence( inR ); | 1797 | remote->addIncidence( inR ); |
1797 | } | 1798 | } |
1798 | } | 1799 | } |
1799 | } else { | 1800 | } else { |
1800 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1801 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1801 | checkExternSyncEvent(eventLSyncSharp, inL); | 1802 | checkExternSyncEvent(eventLSyncSharp, inL); |
1802 | local->deleteIncidence( inL ); | 1803 | local->deleteIncidence( inL ); |
1803 | ++deletedEventL; | 1804 | ++deletedEventL; |
1804 | } else { | 1805 | } else { |
1805 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1806 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1806 | ++addedEventR; | 1807 | ++addedEventR; |
1807 | inL->setLastModified( modifiedCalendar ); | 1808 | inL->setLastModified( modifiedCalendar ); |
1808 | inR = inL->clone(); | 1809 | inR = inL->clone(); |
1809 | inR->setIDStr( ":" ); | 1810 | inR->setIDStr( ":" ); |
1810 | inR->setCalID( 0 );// add to default cal | 1811 | inR->setCalID( 0 );// add to default cal |
1811 | remote->addIncidence( inR ); | 1812 | remote->addIncidence( inR ); |
1812 | } | 1813 | } |
1813 | } | 1814 | } |
1814 | } | 1815 | } |
1815 | } else { | 1816 | } else { |
1816 | ++filteredOUT; | 1817 | ++filteredOUT; |
1817 | } | 1818 | } |
1818 | } | 1819 | } |
1819 | } | 1820 | } |
1820 | inL = el.next(); | 1821 | inL = el.next(); |
1821 | } | 1822 | } |
1822 | int delFut = 0; | 1823 | int delFut = 0; |
1823 | int remRem = 0; | 1824 | int remRem = 0; |
1824 | if ( mSyncManager->mWriteBackInFuture ) { | 1825 | if ( mSyncManager->mWriteBackInFuture ) { |
1825 | er = remote->rawIncidences(); | 1826 | er = remote->rawIncidences(); |
1826 | remRem = er.count(); | 1827 | remRem = er.count(); |
1827 | inR = er.first(); | 1828 | inR = er.first(); |
1828 | QDateTime dt; | 1829 | QDateTime dt; |
1829 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1830 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1830 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1831 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1831 | while ( inR ) { | 1832 | while ( inR ) { |
1832 | if ( inR->typeID() == todoID ) { | 1833 | if ( inR->typeID() == todoID ) { |
1833 | Todo * t = (Todo*)inR; | 1834 | Todo * t = (Todo*)inR; |
1834 | if ( t->hasDueDate() ) | 1835 | if ( t->hasDueDate() ) |
1835 | dt = t->dtDue(); | 1836 | dt = t->dtDue(); |
1836 | else | 1837 | else |
1837 | dt = cur.addSecs( 62 ); | 1838 | dt = cur.addSecs( 62 ); |
1838 | } | 1839 | } |
1839 | else if (inR->typeID() == eventID ) { | 1840 | else if (inR->typeID() == eventID ) { |