author | zautrix <zautrix> | 2005-06-13 10:51:47 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-13 10:51:47 (UTC) |
commit | 4f3ff02932b39bf16b9692c3cb69c101a28b4616 (patch) (unidiff) | |
tree | bae36a7e654c788a0994bb353f3997b495e2459c | |
parent | 2be8214908c52298ba79c8058d340edca5a8b417 (diff) | |
download | kdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.zip kdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.tar.gz kdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.tar.bz2 |
fixx
-rw-r--r-- | korganizer/calendarview.cpp | 63 | ||||
-rw-r--r-- | korganizer/calendarview.h | 7 | ||||
-rw-r--r-- | korganizer/kofilterview.cpp | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 4 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 5 | ||||
-rw-r--r-- | libkcal/calendar.h | 9 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 56 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 6 |
8 files changed, 142 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index b3686aa..07ec459 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -270,384 +270,388 @@ void MissedAlarmTextBrowser::setSource(const QString & n) | |||
270 | 270 | ||
271 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
272 | { | 272 | { |
273 | public: | 273 | public: |
274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
275 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
276 | { | 276 | { |
277 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
278 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
279 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
280 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
282 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
283 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
285 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
286 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
287 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
288 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
289 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
290 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
291 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
293 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
295 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
298 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
302 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
303 | private: | 303 | private: |
304 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
305 | }; | 305 | }; |
306 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
307 | { | 307 | { |
308 | public: | 308 | public: |
309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
310 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
311 | { | 311 | { |
312 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
313 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
314 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
315 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
317 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
319 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
320 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
323 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
325 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
327 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
330 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
334 | private: | 334 | private: |
335 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
336 | }; | 336 | }; |
337 | 337 | ||
338 | 338 | ||
339 | 339 | ||
340 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
341 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
342 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
343 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
344 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
345 | { | 345 | { |
346 | 346 | ||
347 | mEventEditor = 0; | 347 | mEventEditor = 0; |
348 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
349 | 349 | ||
350 | init(); | 350 | init(); |
351 | } | 351 | } |
352 | 352 | ||
353 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
354 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
355 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
356 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
357 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
358 | { | 358 | { |
359 | 359 | ||
360 | mEventEditor = 0; | 360 | mEventEditor = 0; |
361 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
362 | init(); | 362 | init(); |
363 | } | 363 | } |
364 | 364 | ||
365 | void CalendarView::init() | 365 | void CalendarView::init() |
366 | { | 366 | { |
367 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
368 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
369 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
370 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
371 | beamDialog = new KOBeamPrefs(); | 371 | beamDialog = new KOBeamPrefs(); |
372 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
373 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
374 | writeLocale(); | 374 | writeLocale(); |
375 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
378 | mModified = false; | 378 | mModified = false; |
379 | mReadOnly = false; | 379 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
383 | 383 | ||
384 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 386 | ||
387 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 389 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 392 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
395 | 395 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 399 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
402 | 402 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 407 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 409 | mResourceView = 0; |
410 | #else | 410 | #else |
411 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
416 | } else { | 416 | } else { |
417 | mResourceView = 0; | 417 | mResourceView = 0; |
418 | } | 418 | } |
419 | #endif | 419 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 422 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 425 | ||
426 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
427 | #else | 427 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 438 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 445 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
449 | //mainBoxLayout->addWidget (mLeftFrame); | 449 | //mainBoxLayout->addWidget (mLeftFrame); |
450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
451 | "CalendarView::DateNavigator" ); | 451 | "CalendarView::DateNavigator" ); |
452 | #if 0 | 452 | #if 0 |
453 | // FIXME | 453 | // FIXME |
454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
455 | "CalendarView::DateNavigator", QDate::currentDate()); | 455 | "CalendarView::DateNavigator", QDate::currentDate()); |
456 | #endif | 456 | #endif |
457 | // mDateNavigator->blockSignals( true ); | 457 | // mDateNavigator->blockSignals( true ); |
458 | //leftFrameLayout->addWidget( mDateNavigator ); | 458 | //leftFrameLayout->addWidget( mDateNavigator ); |
459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
462 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | ||
463 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | ||
464 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); | ||
465 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | ||
462 | mTodoList->setNavigator( mNavigator ); | 466 | mTodoList->setNavigator( mNavigator ); |
463 | #if 0 | 467 | #if 0 |
464 | if ( QApplication::desktop()->width() < 480 ) { | 468 | if ( QApplication::desktop()->width() < 480 ) { |
465 | leftFrameLayout->addWidget(mFilterView); | 469 | leftFrameLayout->addWidget(mFilterView); |
466 | leftFrameLayout->addWidget(mTodoList, 2 ); | 470 | leftFrameLayout->addWidget(mTodoList, 2 ); |
467 | 471 | ||
468 | } else { | 472 | } else { |
469 | leftFrameLayout->addWidget(mTodoList,2 ); | 473 | leftFrameLayout->addWidget(mTodoList,2 ); |
470 | leftFrameLayout->addWidget(mFilterView ); | 474 | leftFrameLayout->addWidget(mFilterView ); |
471 | } | 475 | } |
472 | #endif | 476 | #endif |
473 | mFilterView->hide(); | 477 | mFilterView->hide(); |
474 | mCalEditView->hide(); | 478 | mCalEditView->hide(); |
475 | QWidget *rightBox = new QWidget( mMainFrame ); | 479 | QWidget *rightBox = new QWidget( mMainFrame ); |
476 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 480 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
477 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 481 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
478 | mRightFrame = new QWidgetStack( rightBox ); | 482 | mRightFrame = new QWidgetStack( rightBox ); |
479 | rightLayout->addWidget( mRightFrame, 10 ); | 483 | rightLayout->addWidget( mRightFrame, 10 ); |
480 | 484 | ||
481 | //mLeftFrame = (QWidget *)leftFrame; | 485 | //mLeftFrame = (QWidget *)leftFrame; |
482 | if ( KOPrefs::instance()->mVerticalScreen ) { | 486 | if ( KOPrefs::instance()->mVerticalScreen ) { |
483 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 487 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
484 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 488 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
485 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 489 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
486 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 490 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
487 | } else { | 491 | } else { |
488 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 492 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
489 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 493 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
490 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 494 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
491 | } | 495 | } |
492 | if ( !KOPrefs::instance()->mShowDateNavigator) | 496 | if ( !KOPrefs::instance()->mShowDateNavigator) |
493 | mDateNavigator->hide(); | 497 | mDateNavigator->hide(); |
494 | //qDebug("Calendarview Size %d %d ", width(), height()); | 498 | //qDebug("Calendarview Size %d %d ", width(), height()); |
495 | #endif | 499 | #endif |
496 | 500 | ||
497 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 501 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
498 | SLOT( showDates( const KCal::DateList & ) ) ); | 502 | SLOT( showDates( const KCal::DateList & ) ) ); |
499 | 503 | ||
500 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 504 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
501 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 505 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
502 | 506 | ||
503 | 507 | ||
504 | 508 | ||
505 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 509 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
506 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 510 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
507 | 511 | ||
508 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 512 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
509 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 513 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
510 | 514 | ||
511 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 515 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
512 | mNavigator, SLOT( selectPreviousYear() ) ); | 516 | mNavigator, SLOT( selectPreviousYear() ) ); |
513 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 517 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
514 | mNavigator, SLOT( selectNextYear() ) ); | 518 | mNavigator, SLOT( selectNextYear() ) ); |
515 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 519 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
516 | mNavigator, SLOT( selectPreviousMonth() ) ); | 520 | mNavigator, SLOT( selectPreviousMonth() ) ); |
517 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 521 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
518 | mNavigator, SLOT( selectNextMonth() ) ); | 522 | mNavigator, SLOT( selectNextMonth() ) ); |
519 | 523 | ||
520 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 524 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
521 | mNavigator, SLOT( selectPrevious() ) ); | 525 | mNavigator, SLOT( selectPrevious() ) ); |
522 | connect( mDateNavigator, SIGNAL( goNext() ), | 526 | connect( mDateNavigator, SIGNAL( goNext() ), |
523 | mNavigator, SLOT( selectNext() ) ); | 527 | mNavigator, SLOT( selectNext() ) ); |
524 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 528 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
525 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 529 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
526 | 530 | ||
527 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 531 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
528 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 532 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
529 | #if 0 | 533 | #if 0 |
530 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 534 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
531 | SLOT( incidenceAdded( Incidence *) ) ); | 535 | SLOT( incidenceAdded( Incidence *) ) ); |
532 | #endif | 536 | #endif |
533 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 537 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
534 | 538 | ||
535 | connect( this, SIGNAL( configChanged() ), | 539 | connect( this, SIGNAL( configChanged() ), |
536 | mDateNavigator, SLOT( updateConfig() ) ); | 540 | mDateNavigator, SLOT( updateConfig() ) ); |
537 | 541 | ||
538 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 542 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
539 | SLOT( newTodo() ) ); | 543 | SLOT( newTodo() ) ); |
540 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 544 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
541 | SLOT( newSubTodo( Todo * ) ) ); | 545 | SLOT( newSubTodo( Todo * ) ) ); |
542 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 546 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
543 | SLOT( editTodo( Todo * ) ) ); | 547 | SLOT( editTodo( Todo * ) ) ); |
544 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 548 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
545 | SLOT( showTodo( Todo *) ) ); | 549 | SLOT( showTodo( Todo *) ) ); |
546 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 550 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
547 | SLOT( deleteTodo( Todo *) ) ); | 551 | SLOT( deleteTodo( Todo *) ) ); |
548 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 552 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
549 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 553 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
550 | SLOT( purgeCompleted() ) ); | 554 | SLOT( purgeCompleted() ) ); |
551 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 555 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
552 | SIGNAL( todoModified( Todo *, int ) ) ); | 556 | SIGNAL( todoModified( Todo *, int ) ) ); |
553 | 557 | ||
554 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 558 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
555 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 559 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
556 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 560 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
557 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 561 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
558 | 562 | ||
559 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 563 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
560 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 564 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
561 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 565 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
562 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 566 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
563 | 567 | ||
564 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 568 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
565 | this, SLOT ( todo_unsub( Todo * ) ) ); | 569 | this, SLOT ( todo_unsub( Todo * ) ) ); |
566 | 570 | ||
567 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 571 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
568 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 572 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
569 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 573 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
570 | SLOT( updateTodo( Todo *, int ) ) ); | 574 | SLOT( updateTodo( Todo *, int ) ) ); |
571 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 575 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
572 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 576 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
573 | 577 | ||
574 | 578 | ||
575 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 579 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
576 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 580 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
577 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 581 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
578 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 582 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
579 | 583 | ||
580 | 584 | ||
581 | 585 | ||
582 | 586 | ||
583 | 587 | ||
584 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 588 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
585 | SLOT(checkClipboard())); | 589 | SLOT(checkClipboard())); |
586 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 590 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
587 | SLOT( processTodoListSelection( Incidence * ) ) ); | 591 | SLOT( processTodoListSelection( Incidence * ) ) ); |
588 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 592 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
589 | 593 | ||
590 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 594 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
591 | 595 | ||
592 | mDateFrame = new QVBox(0,0,WType_Popup); | 596 | mDateFrame = new QVBox(0,0,WType_Popup); |
593 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 597 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
594 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 598 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
595 | mDateFrame->setLineWidth(3); | 599 | mDateFrame->setLineWidth(3); |
596 | mDateFrame->hide(); | 600 | mDateFrame->hide(); |
597 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 601 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
598 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 602 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
599 | 603 | ||
600 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 604 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
601 | 605 | ||
602 | mEventEditor = mDialogManager->getEventEditor(); | 606 | mEventEditor = mDialogManager->getEventEditor(); |
603 | mTodoEditor = mDialogManager->getTodoEditor(); | 607 | mTodoEditor = mDialogManager->getTodoEditor(); |
604 | 608 | ||
605 | mFlagEditDescription = false; | 609 | mFlagEditDescription = false; |
606 | 610 | ||
607 | mSuspendTimer = new QTimer( this ); | 611 | mSuspendTimer = new QTimer( this ); |
608 | mAlarmTimer = new QTimer( this ); | 612 | mAlarmTimer = new QTimer( this ); |
609 | mRecheckAlarmTimer = new QTimer( this ); | 613 | mRecheckAlarmTimer = new QTimer( this ); |
610 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 614 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
611 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 615 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
612 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 616 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
613 | mAlarmDialog = new AlarmDialog( this ); | 617 | mAlarmDialog = new AlarmDialog( this ); |
614 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 618 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
615 | mAlarmDialog->setServerNotification( false ); | 619 | mAlarmDialog->setServerNotification( false ); |
616 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 620 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
617 | 621 | ||
618 | 622 | ||
619 | #ifndef DESKTOP_VERSION | 623 | #ifndef DESKTOP_VERSION |
620 | //US listen for arriving address resultsets | 624 | //US listen for arriving address resultsets |
621 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 625 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
622 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 626 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
623 | #endif | 627 | #endif |
624 | mDateNavigator->setCalendar( mCalendar ); | 628 | mDateNavigator->setCalendar( mCalendar ); |
625 | } | 629 | } |
626 | 630 | ||
627 | 631 | ||
628 | CalendarView::~CalendarView() | 632 | CalendarView::~CalendarView() |
629 | { | 633 | { |
630 | // kdDebug() << "~CalendarView()" << endl; | 634 | // kdDebug() << "~CalendarView()" << endl; |
631 | //qDebug("CalendarView::~CalendarView() "); | 635 | //qDebug("CalendarView::~CalendarView() "); |
632 | delete mDialogManager; | 636 | delete mDialogManager; |
633 | delete mViewManager; | 637 | delete mViewManager; |
634 | delete mStorage; | 638 | delete mStorage; |
635 | delete mDateFrame ; | 639 | delete mDateFrame ; |
636 | delete beamDialog; | 640 | delete beamDialog; |
637 | delete mEventViewerDialog; | 641 | delete mEventViewerDialog; |
638 | //kdDebug() << "~CalendarView() done" << endl; | 642 | //kdDebug() << "~CalendarView() done" << endl; |
639 | } | 643 | } |
640 | void CalendarView::checkAlarms() | 644 | void CalendarView::checkAlarms() |
641 | { | 645 | { |
642 | KConfig *config = KOGlobals::config(); | 646 | KConfig *config = KOGlobals::config(); |
643 | config->setGroup( "AppRun" ); | 647 | config->setGroup( "AppRun" ); |
644 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 648 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
645 | int daysto = dt.daysTo( QDate::currentDate() ); | 649 | int daysto = dt.daysTo( QDate::currentDate() ); |
646 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 650 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
647 | dt = dt.addDays( days ); | 651 | dt = dt.addDays( days ); |
648 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 652 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
649 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 653 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
650 | //qDebug("KO: Reading program stop %d ", secs); | 654 | //qDebug("KO: Reading program stop %d ", secs); |
651 | //secs -= ( 3600 * 24*3 ); // debug only | 655 | //secs -= ( 3600 * 24*3 ); // debug only |
652 | QDateTime latest = dt.addSecs ( secs ); | 656 | QDateTime latest = dt.addSecs ( secs ); |
653 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 657 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
@@ -1645,515 +1649,572 @@ bool CalendarView::importBday() | |||
1645 | // the result should now arrive through method insertBirthdays | 1649 | // the result should now arrive through method insertBirthdays |
1646 | 1650 | ||
1647 | #endif //DESKTOP_VERSION | 1651 | #endif //DESKTOP_VERSION |
1648 | 1652 | ||
1649 | #endif //KORG_NOKABC | 1653 | #endif //KORG_NOKABC |
1650 | 1654 | ||
1651 | 1655 | ||
1652 | return true; | 1656 | return true; |
1653 | } | 1657 | } |
1654 | 1658 | ||
1655 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1659 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1656 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1660 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1657 | const QStringList& anniversaryList, const QStringList& realNameList, | 1661 | const QStringList& anniversaryList, const QStringList& realNameList, |
1658 | const QStringList& emailList, const QStringList& assembledNameList, | 1662 | const QStringList& emailList, const QStringList& assembledNameList, |
1659 | const QStringList& uidList) | 1663 | const QStringList& uidList) |
1660 | { | 1664 | { |
1661 | //qDebug("KO::CalendarView::insertBirthdays"); | 1665 | //qDebug("KO::CalendarView::insertBirthdays"); |
1662 | if (uid == this->name()) | 1666 | if (uid == this->name()) |
1663 | { | 1667 | { |
1664 | int count = birthdayList.count(); | 1668 | int count = birthdayList.count(); |
1665 | int addCount = 0; | 1669 | int addCount = 0; |
1666 | KCal::Attendee* a = 0; | 1670 | KCal::Attendee* a = 0; |
1667 | 1671 | ||
1668 | //qDebug("CalView 1 %i", count); | 1672 | //qDebug("CalView 1 %i", count); |
1669 | 1673 | ||
1670 | QProgressBar bar(count,0 ); | 1674 | QProgressBar bar(count,0 ); |
1671 | int w = 300; | 1675 | int w = 300; |
1672 | if ( QApplication::desktop()->width() < 320 ) | 1676 | if ( QApplication::desktop()->width() < 320 ) |
1673 | w = 220; | 1677 | w = 220; |
1674 | int h = bar.sizeHint().height() ; | 1678 | int h = bar.sizeHint().height() ; |
1675 | int dw = QApplication::desktop()->width(); | 1679 | int dw = QApplication::desktop()->width(); |
1676 | int dh = QApplication::desktop()->height(); | 1680 | int dh = QApplication::desktop()->height(); |
1677 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1681 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1678 | bar.show(); | 1682 | bar.show(); |
1679 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1683 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1680 | qApp->processEvents(); | 1684 | qApp->processEvents(); |
1681 | 1685 | ||
1682 | QDate birthday; | 1686 | QDate birthday; |
1683 | QDate anniversary; | 1687 | QDate anniversary; |
1684 | QString realName; | 1688 | QString realName; |
1685 | QString email; | 1689 | QString email; |
1686 | QString assembledName; | 1690 | QString assembledName; |
1687 | QString uid; | 1691 | QString uid; |
1688 | bool ok = true; | 1692 | bool ok = true; |
1689 | for ( int i = 0; i < count; i++) | 1693 | for ( int i = 0; i < count; i++) |
1690 | { | 1694 | { |
1691 | if ( ! bar.isVisible() ) | 1695 | if ( ! bar.isVisible() ) |
1692 | return; | 1696 | return; |
1693 | bar.setProgress( i ); | 1697 | bar.setProgress( i ); |
1694 | qApp->processEvents(); | 1698 | qApp->processEvents(); |
1695 | 1699 | ||
1696 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1700 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1697 | if (!ok) { | 1701 | if (!ok) { |
1698 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1702 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1699 | } | 1703 | } |
1700 | 1704 | ||
1701 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1705 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1702 | if (!ok) { | 1706 | if (!ok) { |
1703 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1707 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1704 | } | 1708 | } |
1705 | realName = realNameList[i]; | 1709 | realName = realNameList[i]; |
1706 | email = emailList[i]; | 1710 | email = emailList[i]; |
1707 | assembledName = assembledNameList[i]; | 1711 | assembledName = assembledNameList[i]; |
1708 | uid = uidList[i]; | 1712 | uid = uidList[i]; |
1709 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1713 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1710 | 1714 | ||
1711 | if ( birthday.isValid() ){ | 1715 | if ( birthday.isValid() ){ |
1712 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1716 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1713 | KCal::Attendee::ReqParticipant,uid) ; | 1717 | KCal::Attendee::ReqParticipant,uid) ; |
1714 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1718 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1715 | ++addCount; | 1719 | ++addCount; |
1716 | } | 1720 | } |
1717 | 1721 | ||
1718 | if ( anniversary.isValid() ){ | 1722 | if ( anniversary.isValid() ){ |
1719 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1723 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1720 | KCal::Attendee::ReqParticipant,uid) ; | 1724 | KCal::Attendee::ReqParticipant,uid) ; |
1721 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1725 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1722 | ++addCount; | 1726 | ++addCount; |
1723 | } | 1727 | } |
1724 | } | 1728 | } |
1725 | 1729 | ||
1726 | updateView(); | 1730 | updateView(); |
1727 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1731 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1728 | 1732 | ||
1729 | } | 1733 | } |
1730 | 1734 | ||
1731 | } | 1735 | } |
1732 | 1736 | ||
1733 | 1737 | ||
1734 | 1738 | ||
1735 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1739 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1736 | { | 1740 | { |
1737 | //qDebug("addAnni "); | 1741 | //qDebug("addAnni "); |
1738 | Event * ev = new Event(); | 1742 | Event * ev = new Event(); |
1739 | ev->setOrganizer(KOPrefs::instance()->email()); | 1743 | ev->setOrganizer(KOPrefs::instance()->email()); |
1740 | if ( a ) { | 1744 | if ( a ) { |
1741 | ev->addAttendee( a ); | 1745 | ev->addAttendee( a ); |
1742 | } | 1746 | } |
1743 | QString kind; | 1747 | QString kind; |
1744 | if ( birthday ) { | 1748 | if ( birthday ) { |
1745 | kind = i18n( "Birthday" ); | 1749 | kind = i18n( "Birthday" ); |
1746 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1750 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1747 | } | 1751 | } |
1748 | else { | 1752 | else { |
1749 | kind = i18n( "Anniversary" ); | 1753 | kind = i18n( "Anniversary" ); |
1750 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1754 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1751 | } | 1755 | } |
1752 | ev->setCategories( kind ); | 1756 | ev->setCategories( kind ); |
1753 | ev->setDtStart( QDateTime(date) ); | 1757 | ev->setDtStart( QDateTime(date) ); |
1754 | ev->setDtEnd( QDateTime(date) ); | 1758 | ev->setDtEnd( QDateTime(date) ); |
1755 | ev->setFloats( true ); | 1759 | ev->setFloats( true ); |
1756 | Recurrence * rec = ev->recurrence(); | 1760 | Recurrence * rec = ev->recurrence(); |
1757 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1761 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1758 | rec->addYearlyNum( date.month() ); | 1762 | rec->addYearlyNum( date.month() ); |
1759 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1763 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1760 | delete ev; | 1764 | delete ev; |
1761 | return false; | 1765 | return false; |
1762 | } | 1766 | } |
1763 | return true; | 1767 | return true; |
1764 | 1768 | ||
1765 | } | 1769 | } |
1766 | bool CalendarView::importQtopia( const QString &categories, | 1770 | bool CalendarView::importQtopia( const QString &categories, |
1767 | const QString &datebook, | 1771 | const QString &datebook, |
1768 | const QString &todolist ) | 1772 | const QString &todolist ) |
1769 | { | 1773 | { |
1770 | 1774 | ||
1771 | QtopiaFormat qtopiaFormat; | 1775 | QtopiaFormat qtopiaFormat; |
1772 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1776 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1773 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1777 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1774 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1778 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1775 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1779 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1776 | 1780 | ||
1777 | updateView(); | 1781 | updateView(); |
1778 | return true; | 1782 | return true; |
1779 | 1783 | ||
1780 | #if 0 | 1784 | #if 0 |
1781 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1785 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1782 | mCurrentSyncDevice = "qtopia-XML"; | 1786 | mCurrentSyncDevice = "qtopia-XML"; |
1783 | if ( mSyncManager->mAskForPreferences ) | 1787 | if ( mSyncManager->mAskForPreferences ) |
1784 | edit_sync_options(); | 1788 | edit_sync_options(); |
1785 | qApp->processEvents(); | 1789 | qApp->processEvents(); |
1786 | CalendarLocal* calendar = new CalendarLocal(); | 1790 | CalendarLocal* calendar = new CalendarLocal(); |
1787 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1791 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1788 | bool syncOK = false; | 1792 | bool syncOK = false; |
1789 | QtopiaFormat qtopiaFormat; | 1793 | QtopiaFormat qtopiaFormat; |
1790 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1794 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1791 | bool loadOk = true; | 1795 | bool loadOk = true; |
1792 | if ( !categories.isEmpty() ) | 1796 | if ( !categories.isEmpty() ) |
1793 | loadOk = qtopiaFormat.load( calendar, categories ); | 1797 | loadOk = qtopiaFormat.load( calendar, categories ); |
1794 | if ( loadOk && !datebook.isEmpty() ) | 1798 | if ( loadOk && !datebook.isEmpty() ) |
1795 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1799 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1796 | if ( loadOk && !todolist.isEmpty() ) | 1800 | if ( loadOk && !todolist.isEmpty() ) |
1797 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1801 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1798 | 1802 | ||
1799 | if ( loadOk ) { | 1803 | if ( loadOk ) { |
1800 | getEventViewerDialog()->setSyncMode( true ); | 1804 | getEventViewerDialog()->setSyncMode( true ); |
1801 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1805 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1802 | getEventViewerDialog()->setSyncMode( false ); | 1806 | getEventViewerDialog()->setSyncMode( false ); |
1803 | qApp->processEvents(); | 1807 | qApp->processEvents(); |
1804 | if ( syncOK ) { | 1808 | if ( syncOK ) { |
1805 | if ( mSyncManager->mWriteBackFile ) | 1809 | if ( mSyncManager->mWriteBackFile ) |
1806 | { | 1810 | { |
1807 | // write back XML file | 1811 | // write back XML file |
1808 | 1812 | ||
1809 | } | 1813 | } |
1810 | setModified( true ); | 1814 | setModified( true ); |
1811 | } | 1815 | } |
1812 | } else { | 1816 | } else { |
1813 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1817 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1814 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1818 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1815 | question, i18n("Ok")) ; | 1819 | question, i18n("Ok")) ; |
1816 | } | 1820 | } |
1817 | delete calendar; | 1821 | delete calendar; |
1818 | updateView(); | 1822 | updateView(); |
1819 | return syncOK; | 1823 | return syncOK; |
1820 | 1824 | ||
1821 | 1825 | ||
1822 | #endif | 1826 | #endif |
1823 | 1827 | ||
1824 | } | 1828 | } |
1825 | 1829 | ||
1826 | void CalendarView::setSyncEventsReadOnly() | 1830 | void CalendarView::setSyncEventsReadOnly() |
1827 | { | 1831 | { |
1828 | Event * ev; | 1832 | Event * ev; |
1829 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1833 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1830 | ev = eL.first(); | 1834 | ev = eL.first(); |
1831 | while ( ev ) { | 1835 | while ( ev ) { |
1832 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1836 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1833 | ev->setReadOnly( true ); | 1837 | ev->setReadOnly( true ); |
1834 | ev = eL.next(); | 1838 | ev = eL.next(); |
1835 | } | 1839 | } |
1836 | } | 1840 | } |
1841 | |||
1842 | bool CalendarView::loadCalendars() | ||
1843 | { | ||
1844 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | ||
1845 | KopiCalendarFile * cal = calendars.first(); | ||
1846 | mCalendar->setDefaultCalendar( 1 ); | ||
1847 | openCalendar( MainWindow::defaultFileName(), false ); | ||
1848 | cal = calendars.next(); | ||
1849 | while ( cal ) { | ||
1850 | addCalendar( cal ); | ||
1851 | cal = calendars.next(); | ||
1852 | } | ||
1853 | restoreCalendarSettings(); | ||
1854 | mCalendar->reInitAlarmSettings(); | ||
1855 | setSyncEventsReadOnly(); | ||
1856 | updateUnmanagedViews(); | ||
1857 | updateView(); | ||
1858 | } | ||
1859 | bool CalendarView::restoreCalendarSettings() | ||
1860 | { | ||
1861 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | ||
1862 | KopiCalendarFile * cal = calendars.first(); | ||
1863 | while ( cal ) { | ||
1864 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | ||
1865 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | ||
1866 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | ||
1867 | if ( cal->isStandard ) | ||
1868 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | ||
1869 | cal = calendars.next(); | ||
1870 | } | ||
1871 | } | ||
1872 | bool CalendarView::addCalendar( KopiCalendarFile * cal ) | ||
1873 | { | ||
1874 | |||
1875 | if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) | ||
1876 | return true; | ||
1877 | qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); | ||
1878 | KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); | ||
1879 | return false; | ||
1880 | } | ||
1837 | bool CalendarView::openCalendar(QString filename, bool merge) | 1881 | bool CalendarView::openCalendar(QString filename, bool merge) |
1838 | { | 1882 | { |
1839 | 1883 | ||
1840 | if (filename.isEmpty()) { | 1884 | if (filename.isEmpty()) { |
1841 | return false; | 1885 | return false; |
1842 | } | 1886 | } |
1843 | 1887 | ||
1844 | if (!QFile::exists(filename)) { | 1888 | if (!QFile::exists(filename)) { |
1845 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1889 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1846 | return false; | 1890 | return false; |
1847 | } | 1891 | } |
1848 | 1892 | ||
1849 | globalFlagBlockAgenda = 1; | 1893 | globalFlagBlockAgenda = 1; |
1850 | clearAllViews(); | 1894 | clearAllViews(); |
1851 | if (!merge) { | 1895 | if (!merge) { |
1852 | mViewManager->setDocumentId( filename ); | 1896 | mViewManager->setDocumentId( filename ); |
1853 | mCalendar->close(); | 1897 | mCalendar->close(); |
1854 | } | 1898 | } |
1855 | mStorage->setFileName( filename ); | 1899 | mStorage->setFileName( filename ); |
1856 | 1900 | ||
1857 | if ( mStorage->load() ) { | 1901 | if ( mStorage->load() ) { |
1858 | if ( merge ) ;//setModified( true ); | 1902 | if ( merge ) ;//setModified( true ); |
1859 | else { | 1903 | else { |
1860 | //setModified( true ); | 1904 | //setModified( true ); |
1861 | mViewManager->setDocumentId( filename ); | 1905 | mViewManager->setDocumentId( filename ); |
1862 | mDialogManager->setDocumentId( filename ); | 1906 | mDialogManager->setDocumentId( filename ); |
1863 | mTodoList->setDocumentId( filename ); | 1907 | mTodoList->setDocumentId( filename ); |
1864 | } | 1908 | } |
1865 | globalFlagBlockAgenda = 2; | 1909 | globalFlagBlockAgenda = 2; |
1866 | // if ( getLastSyncEvent() ) | 1910 | // if ( getLastSyncEvent() ) |
1867 | // getLastSyncEvent()->setReadOnly( true ); | 1911 | // getLastSyncEvent()->setReadOnly( true ); |
1868 | mCalendar->reInitAlarmSettings(); | 1912 | mCalendar->reInitAlarmSettings(); |
1869 | setSyncEventsReadOnly(); | 1913 | setSyncEventsReadOnly(); |
1870 | updateUnmanagedViews(); | 1914 | updateUnmanagedViews(); |
1871 | updateView(); | 1915 | updateView(); |
1872 | if ( filename != MainWindow::defaultFileName() ) { | 1916 | if ( filename != MainWindow::defaultFileName() ) { |
1873 | saveCalendar( MainWindow::defaultFileName() ); | 1917 | saveCalendar( MainWindow::defaultFileName() ); |
1874 | } else { | 1918 | } else { |
1875 | QFileInfo finf ( MainWindow::defaultFileName()); | 1919 | QFileInfo finf ( MainWindow::defaultFileName()); |
1876 | if ( finf.exists() ) { | 1920 | if ( finf.exists() ) { |
1877 | setLoadedFileVersion( finf.lastModified () ); | 1921 | setLoadedFileVersion( finf.lastModified () ); |
1878 | } | 1922 | } |
1879 | } | 1923 | } |
1880 | return true; | 1924 | return true; |
1881 | } else { | 1925 | } else { |
1882 | // while failing to load, the calendar object could | 1926 | // while failing to load, the calendar object could |
1883 | // have become partially populated. Clear it out. | 1927 | // have become partially populated. Clear it out. |
1884 | if ( !merge ) { | 1928 | if ( !merge ) { |
1885 | mCalendar->close(); | 1929 | mCalendar->close(); |
1886 | mViewManager->setDocumentId( filename ); | 1930 | mViewManager->setDocumentId( filename ); |
1887 | mDialogManager->setDocumentId( filename ); | 1931 | mDialogManager->setDocumentId( filename ); |
1888 | mTodoList->setDocumentId( filename ); | 1932 | mTodoList->setDocumentId( filename ); |
1889 | } | 1933 | } |
1890 | 1934 | ||
1891 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1935 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1892 | 1936 | ||
1893 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1937 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1894 | globalFlagBlockAgenda = 2; | 1938 | globalFlagBlockAgenda = 2; |
1895 | mCalendar->reInitAlarmSettings(); | 1939 | mCalendar->reInitAlarmSettings(); |
1896 | setSyncEventsReadOnly(); | 1940 | setSyncEventsReadOnly(); |
1897 | updateUnmanagedViews(); | 1941 | updateUnmanagedViews(); |
1898 | updateView(); | 1942 | updateView(); |
1899 | } | 1943 | } |
1900 | return false; | 1944 | return false; |
1901 | } | 1945 | } |
1902 | void CalendarView::showOpenError() | 1946 | void CalendarView::showOpenError() |
1903 | { | 1947 | { |
1904 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1948 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1905 | } | 1949 | } |
1906 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1950 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1907 | { | 1951 | { |
1908 | loadedFileVersion = dt; | 1952 | loadedFileVersion = dt; |
1909 | } | 1953 | } |
1910 | bool CalendarView::checkFileChanged(QString fn) | 1954 | bool CalendarView::checkFileChanged(QString fn) |
1911 | { | 1955 | { |
1912 | QFileInfo finf ( fn ); | 1956 | QFileInfo finf ( fn ); |
1913 | if ( !finf.exists() ) | 1957 | if ( !finf.exists() ) |
1914 | return true; | 1958 | return true; |
1915 | QDateTime dt = finf.lastModified (); | 1959 | QDateTime dt = finf.lastModified (); |
1916 | if ( dt <= loadedFileVersion ) | 1960 | if ( dt <= loadedFileVersion ) |
1917 | return false; | 1961 | return false; |
1918 | return true; | 1962 | return true; |
1919 | 1963 | ||
1920 | } | 1964 | } |
1921 | void CalendarView::watchSavedFile() | 1965 | void CalendarView::watchSavedFile() |
1922 | { | 1966 | { |
1923 | QFileInfo finf ( MainWindow::defaultFileName()); | 1967 | QFileInfo finf ( MainWindow::defaultFileName()); |
1924 | if ( !finf.exists() ) | 1968 | if ( !finf.exists() ) |
1925 | return; | 1969 | return; |
1926 | QDateTime dt = finf.lastModified (); | 1970 | QDateTime dt = finf.lastModified (); |
1927 | if ( dt < loadedFileVersion ) { | 1971 | if ( dt < loadedFileVersion ) { |
1928 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1972 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1929 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1973 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1930 | return; | 1974 | return; |
1931 | } | 1975 | } |
1932 | loadedFileVersion = dt; | 1976 | loadedFileVersion = dt; |
1933 | } | 1977 | } |
1934 | 1978 | ||
1935 | bool CalendarView::checkFileVersion(QString fn) | 1979 | bool CalendarView::checkFileVersion(QString fn) |
1936 | { | 1980 | { |
1937 | QFileInfo finf ( fn ); | 1981 | QFileInfo finf ( fn ); |
1938 | if ( !finf.exists() ) | 1982 | if ( !finf.exists() ) |
1939 | return true; | 1983 | return true; |
1940 | QDateTime dt = finf.lastModified (); | 1984 | QDateTime dt = finf.lastModified (); |
1941 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1985 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1942 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1986 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1943 | if ( dt <= loadedFileVersion ) | 1987 | if ( dt <= loadedFileVersion ) |
1944 | return true; | 1988 | return true; |
1945 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1989 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1946 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1990 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1947 | i18n("Sync+save")); | 1991 | i18n("Sync+save")); |
1948 | 1992 | ||
1949 | if ( km == KMessageBox::Cancel ) | 1993 | if ( km == KMessageBox::Cancel ) |
1950 | return false; | 1994 | return false; |
1951 | if ( km == KMessageBox::Yes ) | 1995 | if ( km == KMessageBox::Yes ) |
1952 | return true; | 1996 | return true; |
1953 | 1997 | ||
1954 | setSyncDevice("deleteaftersync" ); | 1998 | setSyncDevice("deleteaftersync" ); |
1955 | mSyncManager->mAskForPreferences = true; | 1999 | mSyncManager->mAskForPreferences = true; |
1956 | mSyncManager->mSyncAlgoPrefs = 3; | 2000 | mSyncManager->mSyncAlgoPrefs = 3; |
1957 | mSyncManager->mWriteBackFile = false; | 2001 | mSyncManager->mWriteBackFile = false; |
1958 | mSyncManager->mWriteBackExistingOnly = false; | 2002 | mSyncManager->mWriteBackExistingOnly = false; |
1959 | mSyncManager->mShowSyncSummary = false; | 2003 | mSyncManager->mShowSyncSummary = false; |
1960 | syncCalendar( fn, 3 ); | 2004 | syncCalendar( fn, 3 ); |
1961 | Event * e = getLastSyncEvent(); | 2005 | Event * e = getLastSyncEvent(); |
1962 | if ( e ) | 2006 | if ( e ) |
1963 | deleteEvent ( e ); | 2007 | deleteEvent ( e ); |
1964 | updateView(); | 2008 | updateView(); |
1965 | return true; | 2009 | return true; |
1966 | } | 2010 | } |
1967 | 2011 | bool CalendarView::saveCalendars() | |
2012 | { | ||
2013 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | ||
2014 | KopiCalendarFile * cal = calendars.first(); | ||
2015 | mCalendar->setDefaultCalendar( 1 ); | ||
2016 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
2017 | saveCalendar( MainWindow::defaultFileName() ); | ||
2018 | cal = calendars.next(); | ||
2019 | while ( cal ) { | ||
2020 | if ( !cal->isReadOnly ) { | ||
2021 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | ||
2022 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
2023 | saveCalendar( cal->mFileName ); | ||
2024 | } | ||
2025 | cal = calendars.next(); | ||
2026 | } | ||
2027 | restoreCalendarSettings(); | ||
2028 | } | ||
1968 | bool CalendarView::saveCalendar( QString filename ) | 2029 | bool CalendarView::saveCalendar( QString filename ) |
1969 | { | 2030 | { |
1970 | 2031 | ||
1971 | // Store back all unsaved data into calendar object | 2032 | // Store back all unsaved data into calendar object |
1972 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2033 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1973 | if ( mViewManager->currentView() ) | 2034 | if ( mViewManager->currentView() ) |
1974 | mViewManager->currentView()->flushView(); | 2035 | mViewManager->currentView()->flushView(); |
1975 | 2036 | ||
1976 | 2037 | ||
1977 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2038 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1978 | mStorage->setSaveFormat( new ICalFormat() ); | 2039 | mStorage->setSaveFormat( new ICalFormat() ); |
1979 | mStorage->setFileName( filename ); | 2040 | mStorage->setFileName( filename ); |
1980 | bool success; | 2041 | bool success; |
1981 | success = mStorage->save(); | 2042 | success = mStorage->save(); |
1982 | if ( !success ) { | 2043 | if ( !success ) { |
1983 | return false; | 2044 | return false; |
1984 | } | 2045 | } |
1985 | if ( filename == MainWindow::defaultFileName() ) { | 2046 | if ( filename == MainWindow::defaultFileName() ) { |
1986 | setLoadedFileVersion( lfv ); | 2047 | setLoadedFileVersion( lfv ); |
1987 | watchSavedFile(); | 2048 | watchSavedFile(); |
1988 | } | 2049 | } |
1989 | return true; | 2050 | return true; |
1990 | } | 2051 | } |
1991 | 2052 | ||
1992 | void CalendarView::closeCalendar() | 2053 | void CalendarView::closeCalendar() |
1993 | { | 2054 | { |
1994 | 2055 | ||
1995 | // child windows no longer valid | 2056 | // child windows no longer valid |
1996 | clearAllViews(); | 2057 | clearAllViews(); |
1997 | emit closingDown(); | 2058 | emit closingDown(); |
1998 | 2059 | ||
1999 | mCalendar->close(); | 2060 | mCalendar->close(); |
2000 | setModified(false); | 2061 | setModified(false); |
2001 | updateView(); | 2062 | updateView(); |
2002 | } | 2063 | } |
2003 | 2064 | ||
2004 | void CalendarView::archiveCalendar() | 2065 | void CalendarView::archiveCalendar() |
2005 | { | 2066 | { |
2006 | mDialogManager->showArchiveDialog(); | 2067 | mDialogManager->showArchiveDialog(); |
2007 | } | 2068 | } |
2008 | 2069 | ||
2009 | 2070 | ||
2010 | void CalendarView::readSettings() | 2071 | void CalendarView::readSettings() |
2011 | { | 2072 | { |
2012 | 2073 | ||
2013 | 2074 | ||
2014 | // mViewManager->showAgendaView(); | 2075 | // mViewManager->showAgendaView(); |
2015 | QString str; | 2076 | QString str; |
2016 | //qDebug("CalendarView::readSettings() "); | 2077 | //qDebug("CalendarView::readSettings() "); |
2017 | // read settings from the KConfig, supplying reasonable | 2078 | // read settings from the KConfig, supplying reasonable |
2018 | // defaults where none are to be found | 2079 | // defaults where none are to be found |
2019 | KConfig *config = KOGlobals::config(); | 2080 | KConfig *config = KOGlobals::config(); |
2020 | #ifndef KORG_NOSPLITTER | 2081 | #ifndef KORG_NOSPLITTER |
2021 | config->setGroup("KOrganizer Geometry"); | 2082 | config->setGroup("KOrganizer Geometry"); |
2022 | 2083 | ||
2023 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 2084 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
2024 | if (sizes.count() != 2) { | 2085 | if (sizes.count() != 2) { |
2025 | sizes << mDateNavigator->minimumSizeHint().width(); | 2086 | sizes << mDateNavigator->minimumSizeHint().width(); |
2026 | sizes << 300; | 2087 | sizes << 300; |
2027 | } | 2088 | } |
2028 | mPanner->setSizes(sizes); | 2089 | mPanner->setSizes(sizes); |
2029 | 2090 | ||
2030 | sizes = config->readIntListEntry("Separator2"); | 2091 | sizes = config->readIntListEntry("Separator2"); |
2031 | if ( ( mResourceView && sizes.count() == 4 ) || | 2092 | if ( ( mResourceView && sizes.count() == 4 ) || |
2032 | ( !mResourceView && sizes.count() == 3 ) ) { | 2093 | ( !mResourceView && sizes.count() == 3 ) ) { |
2033 | mLeftSplitter->setSizes(sizes); | 2094 | mLeftSplitter->setSizes(sizes); |
2034 | } | 2095 | } |
2035 | #endif | 2096 | #endif |
2036 | globalFlagBlockAgenda = 1; | 2097 | globalFlagBlockAgenda = 1; |
2037 | mViewManager->showAgendaView(); | 2098 | mViewManager->showAgendaView(); |
2038 | //mViewManager->readSettings( config ); | 2099 | //mViewManager->readSettings( config ); |
2039 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 2100 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
2040 | readFilterSettings(config); | 2101 | readFilterSettings(config); |
2041 | 2102 | ||
2042 | #ifdef DESKTOP_VERSION | 2103 | #ifdef DESKTOP_VERSION |
2043 | config->setGroup("WidgetLayout"); | 2104 | config->setGroup("WidgetLayout"); |
2044 | QStringList list; | 2105 | QStringList list; |
2045 | list = config->readListEntry("MainLayout"); | 2106 | list = config->readListEntry("MainLayout"); |
2046 | int x,y,w,h; | 2107 | int x,y,w,h; |
2047 | if ( ! list.isEmpty() ) { | 2108 | if ( ! list.isEmpty() ) { |
2048 | x = list[0].toInt(); | 2109 | x = list[0].toInt(); |
2049 | y = list[1].toInt(); | 2110 | y = list[1].toInt(); |
2050 | w = list[2].toInt(); | 2111 | w = list[2].toInt(); |
2051 | h = list[3].toInt(); | 2112 | h = list[3].toInt(); |
2052 | KApplication::testCoords( &x,&y,&w,&h ); | 2113 | KApplication::testCoords( &x,&y,&w,&h ); |
2053 | topLevelWidget()->setGeometry(x,y,w,h); | 2114 | topLevelWidget()->setGeometry(x,y,w,h); |
2054 | 2115 | ||
2055 | } else { | 2116 | } else { |
2056 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 2117 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
2057 | } | 2118 | } |
2058 | list = config->readListEntry("EditEventLayout"); | 2119 | list = config->readListEntry("EditEventLayout"); |
2059 | if ( ! list.isEmpty() ) { | 2120 | if ( ! list.isEmpty() ) { |
2060 | x = list[0].toInt(); | 2121 | x = list[0].toInt(); |
2061 | y = list[1].toInt(); | 2122 | y = list[1].toInt(); |
2062 | w = list[2].toInt(); | 2123 | w = list[2].toInt(); |
2063 | h = list[3].toInt(); | 2124 | h = list[3].toInt(); |
2064 | KApplication::testCoords( &x,&y,&w,&h ); | 2125 | KApplication::testCoords( &x,&y,&w,&h ); |
2065 | mEventEditor->setGeometry(x,y,w,h); | 2126 | mEventEditor->setGeometry(x,y,w,h); |
2066 | 2127 | ||
2067 | } | 2128 | } |
2068 | list = config->readListEntry("EditTodoLayout"); | 2129 | list = config->readListEntry("EditTodoLayout"); |
2069 | if ( ! list.isEmpty() ) { | 2130 | if ( ! list.isEmpty() ) { |
2070 | x = list[0].toInt(); | 2131 | x = list[0].toInt(); |
2071 | y = list[1].toInt(); | 2132 | y = list[1].toInt(); |
2072 | w = list[2].toInt(); | 2133 | w = list[2].toInt(); |
2073 | h = list[3].toInt(); | 2134 | h = list[3].toInt(); |
2074 | KApplication::testCoords( &x,&y,&w,&h ); | 2135 | KApplication::testCoords( &x,&y,&w,&h ); |
2075 | mTodoEditor->setGeometry(x,y,w,h); | 2136 | mTodoEditor->setGeometry(x,y,w,h); |
2076 | 2137 | ||
2077 | } | 2138 | } |
2078 | list = config->readListEntry("ViewerLayout"); | 2139 | list = config->readListEntry("ViewerLayout"); |
2079 | if ( ! list.isEmpty() ) { | 2140 | if ( ! list.isEmpty() ) { |
2080 | x = list[0].toInt(); | 2141 | x = list[0].toInt(); |
2081 | y = list[1].toInt(); | 2142 | y = list[1].toInt(); |
2082 | w = list[2].toInt(); | 2143 | w = list[2].toInt(); |
2083 | h = list[3].toInt(); | 2144 | h = list[3].toInt(); |
2084 | KApplication::testCoords( &x,&y,&w,&h ); | 2145 | KApplication::testCoords( &x,&y,&w,&h ); |
2085 | getEventViewerDialog()->setGeometry(x,y,w,h); | 2146 | getEventViewerDialog()->setGeometry(x,y,w,h); |
2086 | } | 2147 | } |
2087 | #endif | 2148 | #endif |
2088 | config->setGroup( "Views" ); | 2149 | config->setGroup( "Views" ); |
2089 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 2150 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
2090 | 2151 | ||
2091 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 2152 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
2092 | 2153 | ||
2093 | int resetval = 0; | 2154 | int resetval = 0; |
2094 | int maxVal = 0; | 2155 | int maxVal = 0; |
2095 | if (sizes.count() != 3) { | 2156 | if (sizes.count() != 3) { |
2096 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2157 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2097 | resetval = mDateNavigator->sizeHint().width()+2; | 2158 | resetval = mDateNavigator->sizeHint().width()+2; |
2098 | } else { | 2159 | } else { |
2099 | resetval = mDateNavigator->sizeHint().height()+2; | 2160 | resetval = mDateNavigator->sizeHint().height()+2; |
2100 | } | 2161 | } |
2101 | } | 2162 | } |
2102 | if ( resetval ) { | 2163 | if ( resetval ) { |
2103 | sizes.clear(); | 2164 | sizes.clear(); |
2104 | if ( KOPrefs::instance()->mVerticalScreen ) { | 2165 | if ( KOPrefs::instance()->mVerticalScreen ) { |
2105 | maxVal = QApplication::desktop()->width() -10; | 2166 | maxVal = QApplication::desktop()->width() -10; |
2106 | } else { | 2167 | } else { |
2107 | maxVal = QApplication::desktop()->height()-10; | 2168 | maxVal = QApplication::desktop()->height()-10; |
2108 | } | 2169 | } |
2109 | sizes << resetval; | 2170 | sizes << resetval; |
2110 | if ( maxVal < resetval + resetval) | 2171 | if ( maxVal < resetval + resetval) |
2111 | resetval = maxVal - resetval; | 2172 | resetval = maxVal - resetval; |
2112 | sizes << resetval; | 2173 | sizes << resetval; |
2113 | sizes << 100; | 2174 | sizes << 100; |
2114 | } | 2175 | } |
2115 | mLeftFrame->setSizes(sizes); | 2176 | mLeftFrame->setSizes(sizes); |
2116 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2177 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2117 | resetval = 0; | 2178 | resetval = 0; |
2118 | maxVal = 0; | 2179 | maxVal = 0; |
2119 | if (sizes.count() != 2) { | 2180 | if (sizes.count() != 2) { |
2120 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2181 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2121 | resetval = mDateNavigator->sizeHint().width()+2; | 2182 | resetval = mDateNavigator->sizeHint().width()+2; |
2122 | } else { | 2183 | } else { |
2123 | resetval = mDateNavigator->sizeHint().height()+2; | 2184 | resetval = mDateNavigator->sizeHint().height()+2; |
2124 | } | 2185 | } |
2125 | } | 2186 | } |
2126 | if ( resetval ) { | 2187 | if ( resetval ) { |
2127 | sizes.clear(); | 2188 | sizes.clear(); |
2128 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2189 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2129 | maxVal = QApplication::desktop()->width() -10; | 2190 | maxVal = QApplication::desktop()->width() -10; |
2130 | } else { | 2191 | } else { |
2131 | maxVal = QApplication::desktop()->height()-10; | 2192 | maxVal = QApplication::desktop()->height()-10; |
2132 | } | 2193 | } |
2133 | sizes << resetval; | 2194 | sizes << resetval; |
2134 | if ( maxVal < resetval + resetval) | 2195 | if ( maxVal < resetval + resetval) |
2135 | resetval = maxVal - resetval; | 2196 | resetval = maxVal - resetval; |
2136 | sizes << resetval; | 2197 | sizes << resetval; |
2137 | } | 2198 | } |
2138 | mMainFrame->setSizes(sizes); | 2199 | mMainFrame->setSizes(sizes); |
2139 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2200 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2140 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2201 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2141 | else mNavigator->selectDates( dateCount ); | 2202 | else mNavigator->selectDates( dateCount ); |
2142 | // mViewManager->readSettings( config ); | 2203 | // mViewManager->readSettings( config ); |
2143 | updateConfig(); | 2204 | updateConfig(); |
2144 | globalFlagBlockAgenda = 2; | 2205 | globalFlagBlockAgenda = 2; |
2145 | mViewManager->readSettings( config ); | 2206 | mViewManager->readSettings( config ); |
2146 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2207 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2147 | } | 2208 | } |
2148 | 2209 | ||
2149 | 2210 | ||
2150 | void CalendarView::writeSettings() | 2211 | void CalendarView::writeSettings() |
2151 | { | 2212 | { |
2152 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2213 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2153 | 2214 | ||
2154 | KConfig *config = KOGlobals::config(); | 2215 | KConfig *config = KOGlobals::config(); |
2155 | 2216 | ||
2156 | mViewManager->writeSettings( config ); | 2217 | mViewManager->writeSettings( config ); |
2157 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2218 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2158 | mDialogManager->writeSettings( config ); | 2219 | mDialogManager->writeSettings( config ); |
2159 | //KOPrefs::instance()->usrWriteConfig(); | 2220 | //KOPrefs::instance()->usrWriteConfig(); |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index cdce072..0144ba4 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,416 +1,421 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | #include <KDGanttMinimizeSplitter.h> | 42 | #include <KDGanttMinimizeSplitter.h> |
43 | 43 | ||
44 | #include <korganizer/calendarviewbase.h> | 44 | #include <korganizer/calendarviewbase.h> |
45 | 45 | ||
46 | #include <ksyncmanager.h> | 46 | #include <ksyncmanager.h> |
47 | //#include <koprefs.h> | ||
47 | 48 | ||
48 | class QWidgetStack; | 49 | class QWidgetStack; |
49 | class QSplitter; | 50 | class QSplitter; |
50 | 51 | class KopiCalendarFile; | |
51 | class CalPrinter; | 52 | class CalPrinter; |
52 | class KOFilterView; | 53 | class KOFilterView; |
53 | class KOCalEditView; | 54 | class KOCalEditView; |
54 | class KOViewManager; | 55 | class KOViewManager; |
55 | class KODialogManager; | 56 | class KODialogManager; |
56 | class KOTodoView; | 57 | class KOTodoView; |
57 | class KDateNavigator; | 58 | class KDateNavigator; |
58 | class DateNavigatorContainer; | 59 | class DateNavigatorContainer; |
59 | class DateNavigator; | 60 | class DateNavigator; |
60 | class KOIncidenceEditor; | 61 | class KOIncidenceEditor; |
61 | class KDatePicker; | 62 | class KDatePicker; |
62 | class ResourceView; | 63 | class ResourceView; |
63 | class KOEventEditor; | 64 | class KOEventEditor; |
64 | class KOTodoEditor ; | 65 | class KOTodoEditor ; |
65 | class KOEventViewerDialog; | 66 | class KOEventViewerDialog; |
66 | class KOBeamPrefs; | 67 | class KOBeamPrefs; |
67 | class KSyncProfile; | 68 | class KSyncProfile; |
68 | class AlarmDialog; | 69 | class AlarmDialog; |
69 | class KCal::Attendee; | 70 | class KCal::Attendee; |
70 | 71 | ||
71 | namespace KCal { class FileStorage; } | 72 | namespace KCal { class FileStorage; } |
72 | 73 | ||
73 | using namespace KCal; | 74 | using namespace KCal; |
74 | 75 | ||
75 | /** | 76 | /** |
76 | This is the main calendar widget. It provides the different vies on t he | 77 | This is the main calendar widget. It provides the different vies on t he |
77 | calendar data as well as the date navigator. It also handles synchronisation | 78 | calendar data as well as the date navigator. It also handles synchronisation |
78 | of the different views and controls the different dialogs like preferences, | 79 | of the different views and controls the different dialogs like preferences, |
79 | event editor, search dialog etc. | 80 | event editor, search dialog etc. |
80 | 81 | ||
81 | @short main calendar view widget | 82 | @short main calendar view widget |
82 | @author Cornelius Schumacher | 83 | @author Cornelius Schumacher |
83 | */ | 84 | */ |
84 | 85 | ||
85 | #include <qtextbrowser.h> | 86 | #include <qtextbrowser.h> |
86 | #include <qtextcodec.h> | 87 | #include <qtextcodec.h> |
87 | 88 | ||
88 | class MissedAlarmTextBrowser : public QTextBrowser { | 89 | class MissedAlarmTextBrowser : public QTextBrowser { |
89 | Q_OBJECT | 90 | Q_OBJECT |
90 | public: | 91 | public: |
91 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); | 92 | MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); |
92 | ~MissedAlarmTextBrowser(); | 93 | ~MissedAlarmTextBrowser(); |
93 | void setSource(const QString & n); | 94 | void setSource(const QString & n); |
94 | 95 | ||
95 | private: | 96 | private: |
96 | Incidence * getNextInc(QDateTime start ); | 97 | Incidence * getNextInc(QDateTime start ); |
97 | QPtrList<Incidence> mAlarms; | 98 | QPtrList<Incidence> mAlarms; |
98 | signals: | 99 | signals: |
99 | void showIncidence( QString uid); | 100 | void showIncidence( QString uid); |
100 | }; | 101 | }; |
101 | 102 | ||
102 | 103 | ||
103 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 104 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
104 | { | 105 | { |
105 | Q_OBJECT | 106 | Q_OBJECT |
106 | public: | 107 | public: |
107 | /** | 108 | /** |
108 | Constructs a new calendar view widget. | 109 | Constructs a new calendar view widget. |
109 | 110 | ||
110 | @param calendar calendar document | 111 | @param calendar calendar document |
111 | @param parent parent window | 112 | @param parent parent window |
112 | @param name Qt internal widget object name | 113 | @param name Qt internal widget object name |
113 | */ | 114 | */ |
114 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 115 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
115 | const char *name = 0 ); | 116 | const char *name = 0 ); |
116 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 117 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
117 | const char *name = 0 ); | 118 | const char *name = 0 ); |
118 | virtual ~CalendarView(); | 119 | virtual ~CalendarView(); |
119 | 120 | ||
120 | Calendar *calendar() { return mCalendar; } | 121 | Calendar *calendar() { return mCalendar; } |
121 | 122 | ||
122 | KOViewManager *viewManager(); | 123 | KOViewManager *viewManager(); |
123 | KODialogManager *dialogManager(); | 124 | KODialogManager *dialogManager(); |
124 | 125 | ||
125 | QDate startDate(); | 126 | QDate startDate(); |
126 | QDate endDate(); | 127 | QDate endDate(); |
127 | 128 | ||
128 | QWidgetStack *viewStack(); | 129 | QWidgetStack *viewStack(); |
129 | QWidget *leftFrame(); | 130 | QWidget *leftFrame(); |
130 | 131 | ||
131 | DateNavigator *dateNavigator(); | 132 | DateNavigator *dateNavigator(); |
132 | KDateNavigator *dateNavigatorWidget(); | 133 | KDateNavigator *dateNavigatorWidget(); |
133 | 134 | ||
134 | void addView(KOrg::BaseView *); | 135 | void addView(KOrg::BaseView *); |
135 | void showView(KOrg::BaseView *); | 136 | void showView(KOrg::BaseView *); |
136 | KOEventViewerDialog* getEventViewerDialog(); | 137 | KOEventViewerDialog* getEventViewerDialog(); |
137 | Incidence *currentSelection(); | 138 | Incidence *currentSelection(); |
138 | 139 | ||
139 | signals: | 140 | signals: |
140 | void save (); | 141 | void save (); |
141 | void saveStopTimer (); | 142 | void saveStopTimer (); |
142 | void tempDisableBR(bool); | 143 | void tempDisableBR(bool); |
143 | /** This todo has been modified */ | 144 | /** This todo has been modified */ |
144 | void todoModified(Todo *, int); | 145 | void todoModified(Todo *, int); |
145 | 146 | ||
146 | /** when change is made to options dialog, the topwidget will catch this | 147 | /** when change is made to options dialog, the topwidget will catch this |
147 | * and emit this signal which notifies all widgets which have registered | 148 | * and emit this signal which notifies all widgets which have registered |
148 | * for notification to update their settings. */ | 149 | * for notification to update their settings. */ |
149 | void configChanged(); | 150 | void configChanged(); |
150 | /** emitted when the topwidget is closing down, so that any attached | 151 | /** emitted when the topwidget is closing down, so that any attached |
151 | child windows can also close. */ | 152 | child windows can also close. */ |
152 | void closingDown(); | 153 | void closingDown(); |
153 | /** emitted right before we die */ | 154 | /** emitted right before we die */ |
154 | void closed(QWidget *); | 155 | void closed(QWidget *); |
155 | 156 | ||
156 | /** Emitted when state of modified flag changes */ | 157 | /** Emitted when state of modified flag changes */ |
157 | void modifiedChanged(bool); | 158 | void modifiedChanged(bool); |
158 | void signalmodified(); | 159 | void signalmodified(); |
159 | 160 | ||
160 | /** Emitted when state of read-only flag changes */ | 161 | /** Emitted when state of read-only flag changes */ |
161 | void readOnlyChanged(bool); | 162 | void readOnlyChanged(bool); |
162 | 163 | ||
163 | /** Emitted when the unit of navigation changes */ | 164 | /** Emitted when the unit of navigation changes */ |
164 | void changeNavStringPrev(const QString &); | 165 | void changeNavStringPrev(const QString &); |
165 | void changeNavStringNext(const QString &); | 166 | void changeNavStringNext(const QString &); |
166 | 167 | ||
167 | /** Emitted when state of events selection has changed and user is organizer*/ | 168 | /** Emitted when state of events selection has changed and user is organizer*/ |
168 | void organizerEventsSelected(bool); | 169 | void organizerEventsSelected(bool); |
169 | /** Emitted when state of events selection has changed and user is attendee*/ | 170 | /** Emitted when state of events selection has changed and user is attendee*/ |
170 | void groupEventsSelected(bool); | 171 | void groupEventsSelected(bool); |
171 | /** | 172 | /** |
172 | Emitted when an incidence gets selected. If the selection is cleared the | 173 | Emitted when an incidence gets selected. If the selection is cleared the |
173 | signal is emitted with 0 as argument. | 174 | signal is emitted with 0 as argument. |
174 | */ | 175 | */ |
175 | void incidenceSelected( Incidence * ); | 176 | void incidenceSelected( Incidence * ); |
176 | /** Emitted, when a todoitem is selected or deselected. */ | 177 | /** Emitted, when a todoitem is selected or deselected. */ |
177 | void todoSelected( bool ); | 178 | void todoSelected( bool ); |
178 | 179 | ||
179 | /** | 180 | /** |
180 | Emitted, when clipboard content changes. Parameter indicates if paste | 181 | Emitted, when clipboard content changes. Parameter indicates if paste |
181 | is possible or not. | 182 | is possible or not. |
182 | */ | 183 | */ |
183 | void pasteEnabled(bool); | 184 | void pasteEnabled(bool); |
184 | 185 | ||
185 | /** Emitted, when the number of incoming messages has changed. */ | 186 | /** Emitted, when the number of incoming messages has changed. */ |
186 | void numIncomingChanged(int); | 187 | void numIncomingChanged(int); |
187 | 188 | ||
188 | /** Emitted, when the number of outgoing messages has changed. */ | 189 | /** Emitted, when the number of outgoing messages has changed. */ |
189 | void numOutgoingChanged(int); | 190 | void numOutgoingChanged(int); |
190 | 191 | ||
191 | /** Send status message, which can e.g. be displayed in the status bar. */ | 192 | /** Send status message, which can e.g. be displayed in the status bar. */ |
192 | void statusMessage(const QString &); | 193 | void statusMessage(const QString &); |
193 | 194 | ||
194 | void calendarViewExpanded( bool ); | 195 | void calendarViewExpanded( bool ); |
195 | void updateSearchDialog(); | 196 | void updateSearchDialog(); |
196 | 197 | ||
197 | 198 | ||
198 | public slots: | 199 | public slots: |
199 | void checkAlarms(); | 200 | void checkAlarms(); |
200 | void slotprintSelInc(); | 201 | void slotprintSelInc(); |
201 | void showNextAlarms(); | 202 | void showNextAlarms(); |
202 | void showOpenError(); | 203 | void showOpenError(); |
203 | void watchSavedFile(); | 204 | void watchSavedFile(); |
204 | void recheckTimerAlarm(); | 205 | void recheckTimerAlarm(); |
205 | void checkNextTimerAlarm(); | 206 | void checkNextTimerAlarm(); |
206 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 207 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
207 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 208 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
208 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 209 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
209 | 210 | ||
210 | /** options dialog made a changed to the configuration. we catch this | 211 | /** options dialog made a changed to the configuration. we catch this |
211 | * and notify all widgets which need to update their configuration. */ | 212 | * and notify all widgets which need to update their configuration. */ |
212 | void updateConfig(); | 213 | void updateConfig(); |
213 | 214 | ||
214 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 215 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
215 | const QStringList& anniversaryList, const QStringList& realNameList, | 216 | const QStringList& anniversaryList, const QStringList& realNameList, |
216 | const QStringList& emailList, const QStringList& assembledNameList, | 217 | const QStringList& emailList, const QStringList& assembledNameList, |
217 | const QStringList& uidList); | 218 | const QStringList& uidList); |
218 | 219 | ||
219 | /** | 220 | /** |
220 | Load calendar from file \a filename. If \a merge is true, load | 221 | Load calendar from file \a filename. If \a merge is true, load |
221 | calendar into existing one, if it is false, clear calendar, before | 222 | calendar into existing one, if it is false, clear calendar, before |
222 | loading. Return true, if calendar could be successfully loaded. | 223 | loading. Return true, if calendar could be successfully loaded. |
223 | */ | 224 | */ |
224 | bool openCalendar(QString filename, bool merge=false); | 225 | bool openCalendar(QString filename, bool merge=false); |
226 | bool loadCalendars(); | ||
227 | bool saveCalendars(); | ||
228 | bool restoreCalendarSettings(); | ||
229 | bool addCalendar( KopiCalendarFile * ); | ||
225 | bool syncCalendar(QString filename,int mode = 0 ); | 230 | bool syncCalendar(QString filename,int mode = 0 ); |
226 | 231 | ||
227 | /** | 232 | /** |
228 | Save calendar data to file. Return true if calendar could be | 233 | Save calendar data to file. Return true if calendar could be |
229 | successfully saved. | 234 | successfully saved. |
230 | */ | 235 | */ |
231 | bool saveCalendar(QString filename); | 236 | bool saveCalendar(QString filename); |
232 | 237 | ||
233 | /** | 238 | /** |
234 | Close calendar. Clear calendar data and reset views to display an empty | 239 | Close calendar. Clear calendar data and reset views to display an empty |
235 | calendar. | 240 | calendar. |
236 | */ | 241 | */ |
237 | void closeCalendar(); | 242 | void closeCalendar(); |
238 | 243 | ||
239 | /** Archive old events of calendar */ | 244 | /** Archive old events of calendar */ |
240 | void archiveCalendar(); | 245 | void archiveCalendar(); |
241 | 246 | ||
242 | void showIncidence(); | 247 | void showIncidence(); |
243 | void editIncidence(); | 248 | void editIncidence(); |
244 | void editIncidenceDescription(); | 249 | void editIncidenceDescription(); |
245 | void deleteIncidence(); | 250 | void deleteIncidence(); |
246 | void cloneIncidence(); | 251 | void cloneIncidence(); |
247 | void moveIncidence(); | 252 | void moveIncidence(); |
248 | void beamIncidence(); | 253 | void beamIncidence(); |
249 | void toggleCancelIncidence(); | 254 | void toggleCancelIncidence(); |
250 | 255 | ||
251 | /** create an editeventwin with supplied date/time, and if bool is true, | 256 | /** create an editeventwin with supplied date/time, and if bool is true, |
252 | * make the event take all day. */ | 257 | * make the event take all day. */ |
253 | void newEvent(QDateTime, QDateTime, bool allDay ); | 258 | void newEvent(QDateTime, QDateTime, bool allDay ); |
254 | void newEvent(QDateTime, QDateTime); | 259 | void newEvent(QDateTime, QDateTime); |
255 | void newEvent(QDateTime fh); | 260 | void newEvent(QDateTime fh); |
256 | void newEvent(QDate dt); | 261 | void newEvent(QDate dt); |
257 | /** create new event without having a date hint. Takes current date as | 262 | /** create new event without having a date hint. Takes current date as |
258 | default hint. */ | 263 | default hint. */ |
259 | void newEvent(); | 264 | void newEvent(); |
260 | void newFloatingEvent(); | 265 | void newFloatingEvent(); |
261 | 266 | ||
262 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 267 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
263 | void showIncidence(Incidence *); | 268 | void showIncidence(Incidence *); |
264 | void showIncidence(QString uid); | 269 | void showIncidence(QString uid); |
265 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 270 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
266 | void editIncidence(Incidence *); | 271 | void editIncidence(Incidence *); |
267 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 272 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
268 | void deleteIncidence(Incidence *); | 273 | void deleteIncidence(Incidence *); |
269 | void cloneIncidence(Incidence *); | 274 | void cloneIncidence(Incidence *); |
270 | void cancelIncidence(Incidence *); | 275 | void cancelIncidence(Incidence *); |
271 | /** Create an editor for the supplied event. */ | 276 | /** Create an editor for the supplied event. */ |
272 | void editEvent(Event *); | 277 | void editEvent(Event *); |
273 | /** Delete the supplied event. */ | 278 | /** Delete the supplied event. */ |
274 | void deleteEvent(Event *); | 279 | void deleteEvent(Event *); |
275 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 280 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
276 | found. */ | 281 | found. */ |
277 | bool deleteEvent(const QString &uid); | 282 | bool deleteEvent(const QString &uid); |
278 | /** Create a read-only viewer dialog for the supplied event. */ | 283 | /** Create a read-only viewer dialog for the supplied event. */ |
279 | void showEvent(Event *); | 284 | void showEvent(Event *); |
280 | 285 | ||
281 | void editJournal(Journal *); | 286 | void editJournal(Journal *); |
282 | void showJournal(Journal *); | 287 | void showJournal(Journal *); |
283 | void deleteJournal(Journal *); | 288 | void deleteJournal(Journal *); |
284 | /** Create an editor dialog for a todo */ | 289 | /** Create an editor dialog for a todo */ |
285 | void editTodo(Todo *); | 290 | void editTodo(Todo *); |
286 | /** Create a read-only viewer dialog for the supplied todo */ | 291 | /** Create a read-only viewer dialog for the supplied todo */ |
287 | void showTodo(Todo *); | 292 | void showTodo(Todo *); |
288 | /** create new todo */ | 293 | /** create new todo */ |
289 | void newTodo(); | 294 | void newTodo(); |
290 | void newTodoDateTime(QDateTime, bool allday); | 295 | void newTodoDateTime(QDateTime, bool allday); |
291 | /** create new todo with a parent todo */ | 296 | /** create new todo with a parent todo */ |
292 | void newSubTodo(); | 297 | void newSubTodo(); |
293 | /** create new todo with a parent todo */ | 298 | /** create new todo with a parent todo */ |
294 | void newSubTodo(Todo *); | 299 | void newSubTodo(Todo *); |
295 | /** Delete todo */ | 300 | /** Delete todo */ |
296 | void deleteTodo(Todo *); | 301 | void deleteTodo(Todo *); |
297 | 302 | ||
298 | 303 | ||
299 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 304 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
300 | * emitted as result. */ | 305 | * emitted as result. */ |
301 | void checkClipboard(); | 306 | void checkClipboard(); |
302 | 307 | ||
303 | /** using the KConfig associated with the kapp variable, read in the | 308 | /** using the KConfig associated with the kapp variable, read in the |
304 | * settings from the config file. | 309 | * settings from the config file. |
305 | */ | 310 | */ |
306 | void readSettings(); | 311 | void readSettings(); |
307 | 312 | ||
308 | /** write current state to config file. */ | 313 | /** write current state to config file. */ |
309 | void writeSettings(); | 314 | void writeSettings(); |
310 | 315 | ||
311 | /** read settings for calendar filters */ | 316 | /** read settings for calendar filters */ |
312 | void readFilterSettings(KConfig *config); | 317 | void readFilterSettings(KConfig *config); |
313 | 318 | ||
314 | /** write settings for calendar filters */ | 319 | /** write settings for calendar filters */ |
315 | void writeFilterSettings(KConfig *config); | 320 | void writeFilterSettings(KConfig *config); |
316 | 321 | ||
317 | /** passes on the message that an event has changed to the currently | 322 | /** passes on the message that an event has changed to the currently |
318 | * activated view so that it can make appropriate display changes. */ | 323 | * activated view so that it can make appropriate display changes. */ |
319 | void changeEventDisplay(Event *, int); | 324 | void changeEventDisplay(Event *, int); |
320 | void changeIncidenceDisplay(Incidence *, int); | 325 | void changeIncidenceDisplay(Incidence *, int); |
321 | void changeTodoDisplay(Todo *, int); | 326 | void changeTodoDisplay(Todo *, int); |
322 | 327 | ||
323 | void eventAdded(Event *); | 328 | void eventAdded(Event *); |
324 | void eventChanged(Event *); | 329 | void eventChanged(Event *); |
325 | void eventToBeDeleted(Event *); | 330 | void eventToBeDeleted(Event *); |
326 | void eventDeleted(); | 331 | void eventDeleted(); |
327 | 332 | ||
328 | void todoAdded(Todo *); | 333 | void todoAdded(Todo *); |
329 | void todoChanged(Todo *); | 334 | void todoChanged(Todo *); |
330 | void todoToBeDeleted(Todo *); | 335 | void todoToBeDeleted(Todo *); |
331 | void todoDeleted(); | 336 | void todoDeleted(); |
332 | 337 | ||
333 | void updateView(const QDate &start, const QDate &end); | 338 | void updateView(const QDate &start, const QDate &end); |
334 | void updateView(); | 339 | void updateView(); |
335 | void clearAllViews(); | 340 | void clearAllViews(); |
336 | 341 | ||
337 | /** Full update of visible todo views */ | 342 | /** Full update of visible todo views */ |
338 | void updateTodoViews(); | 343 | void updateTodoViews(); |
339 | 344 | ||
340 | void updateUnmanagedViews(); | 345 | void updateUnmanagedViews(); |
341 | 346 | ||
342 | /** cut the current appointment to the clipboard */ | 347 | /** cut the current appointment to the clipboard */ |
343 | void edit_cut(); | 348 | void edit_cut(); |
344 | 349 | ||
345 | /** copy the current appointment(s) to the clipboard */ | 350 | /** copy the current appointment(s) to the clipboard */ |
346 | void edit_copy(); | 351 | void edit_copy(); |
347 | 352 | ||
348 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 353 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
349 | void edit_paste(); | 354 | void edit_paste(); |
350 | 355 | ||
351 | /** edit viewing and configuration options. */ | 356 | /** edit viewing and configuration options. */ |
352 | void edit_options(); | 357 | void edit_options(); |
353 | void edit_global_options(); | 358 | void edit_global_options(); |
354 | /** | 359 | /** |
355 | Functions for printing, previewing a print, and setting up printing | 360 | Functions for printing, previewing a print, and setting up printing |
356 | parameters. | 361 | parameters. |
357 | */ | 362 | */ |
358 | void print(); | 363 | void print(); |
359 | void printSetup(); | 364 | void printSetup(); |
360 | void printPreview(); | 365 | void printPreview(); |
361 | 366 | ||
362 | /** Export as iCalendar file */ | 367 | /** Export as iCalendar file */ |
363 | void exportICalendar(); | 368 | void exportICalendar(); |
364 | 369 | ||
365 | /** Export as vCalendar file */ | 370 | /** Export as vCalendar file */ |
366 | bool exportVCalendar( QString fn); | 371 | bool exportVCalendar( QString fn); |
367 | 372 | ||
368 | /** pop up a dialog to show an existing appointment. */ | 373 | /** pop up a dialog to show an existing appointment. */ |
369 | void appointment_show(); | 374 | void appointment_show(); |
370 | /** | 375 | /** |
371 | * pop up an Appointment Dialog to edit an existing appointment.Get | 376 | * pop up an Appointment Dialog to edit an existing appointment.Get |
372 | * information on the appointment from the list of unique IDs that is | 377 | * information on the appointment from the list of unique IDs that is |
373 | * currently in the View, called currIds. | 378 | * currently in the View, called currIds. |
374 | */ | 379 | */ |
375 | void appointment_edit(); | 380 | void appointment_edit(); |
376 | /** | 381 | /** |
377 | * pop up dialog confirming deletion of currently selected event in the | 382 | * pop up dialog confirming deletion of currently selected event in the |
378 | * View. | 383 | * View. |
379 | */ | 384 | */ |
380 | void appointment_delete(); | 385 | void appointment_delete(); |
381 | 386 | ||
382 | /** mails the currently selected event to a particular user as a vCalendar | 387 | /** mails the currently selected event to a particular user as a vCalendar |
383 | attachment. */ | 388 | attachment. */ |
384 | void action_mail(); | 389 | void action_mail(); |
385 | 390 | ||
386 | /* frees a subtodo from it's relation */ | 391 | /* frees a subtodo from it's relation */ |
387 | void todo_unsub( Todo * ); | 392 | void todo_unsub( Todo * ); |
388 | void todo_resub( Todo * parent, Todo * sub ); | 393 | void todo_resub( Todo * parent, Todo * sub ); |
389 | 394 | ||
390 | /** Take ownership of selected event. */ | 395 | /** Take ownership of selected event. */ |
391 | void takeOverEvent(); | 396 | void takeOverEvent(); |
392 | 397 | ||
393 | /** Take ownership of all events in calendar. */ | 398 | /** Take ownership of all events in calendar. */ |
394 | void takeOverCalendar(); | 399 | void takeOverCalendar(); |
395 | 400 | ||
396 | /** query whether or not the calendar is "dirty". */ | 401 | /** query whether or not the calendar is "dirty". */ |
397 | bool isModified(); | 402 | bool isModified(); |
398 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 403 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
399 | void setModified(bool modified=true); | 404 | void setModified(bool modified=true); |
400 | 405 | ||
401 | /** query if the calendar is read-only. */ | 406 | /** query if the calendar is read-only. */ |
402 | bool isReadOnly(); | 407 | bool isReadOnly(); |
403 | /** set state of calendar to read-only */ | 408 | /** set state of calendar to read-only */ |
404 | void setReadOnly(bool readOnly=true); | 409 | void setReadOnly(bool readOnly=true); |
405 | 410 | ||
406 | void eventUpdated(Incidence *); | 411 | void eventUpdated(Incidence *); |
407 | 412 | ||
408 | /* iTIP scheduling actions */ | 413 | /* iTIP scheduling actions */ |
409 | void schedule_publish(Incidence *incidence = 0); | 414 | void schedule_publish(Incidence *incidence = 0); |
410 | void schedule_request(Incidence *incidence = 0); | 415 | void schedule_request(Incidence *incidence = 0); |
411 | void schedule_refresh(Incidence *incidence = 0); | 416 | void schedule_refresh(Incidence *incidence = 0); |
412 | void schedule_cancel(Incidence *incidence = 0); | 417 | void schedule_cancel(Incidence *incidence = 0); |
413 | void schedule_add(Incidence *incidence = 0); | 418 | void schedule_add(Incidence *incidence = 0); |
414 | void schedule_reply(Incidence *incidence = 0); | 419 | void schedule_reply(Incidence *incidence = 0); |
415 | void schedule_counter(Incidence *incidence = 0); | 420 | void schedule_counter(Incidence *incidence = 0); |
416 | void schedule_declinecounter(Incidence *incidence = 0); | 421 | void schedule_declinecounter(Incidence *incidence = 0); |
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index 2dd4567..29a4393 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -1,261 +1,261 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qdialog.h> | 29 | #include <qdialog.h> |
30 | 30 | ||
31 | 31 | ||
32 | #include <libkcal/calfilter.h> | 32 | #include <libkcal/calfilter.h> |
33 | 33 | ||
34 | #include "kofilterview.h" | 34 | #include "kofilterview.h" |
35 | #include "koprefs.h" | 35 | #include "koprefs.h" |
36 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | #include <kcolorbutton.h> | 38 | #include <kcolorbutton.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | 40 | ||
41 | 41 | ||
42 | #include <kurlrequester.h> | 42 | #include <kurlrequester.h> |
43 | #include <klineedit.h> | 43 | #include <klineedit.h> |
44 | 44 | ||
45 | class KONewCalPrefs : public QDialog | 45 | class KONewCalPrefs : public QDialog |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : | 48 | KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : |
49 | QDialog( parent, name, true ) | 49 | QDialog( parent, name, true ) |
50 | { | 50 | { |
51 | setCaption( i18n("Add new Calendar") ); | 51 | setCaption( i18n("Add new Calendar") ); |
52 | QVBoxLayout* lay = new QVBoxLayout( this ); | 52 | QVBoxLayout* lay = new QVBoxLayout( this ); |
53 | lay->setSpacing( 3 ); | 53 | lay->setSpacing( 3 ); |
54 | lay->setMargin( 3 ); | 54 | lay->setMargin( 3 ); |
55 | QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); | 55 | QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); |
56 | lay->addWidget( lab ); | 56 | lay->addWidget( lab ); |
57 | nameE = new KLineEdit( this ); | 57 | nameE = new KLineEdit( this ); |
58 | lay->addWidget( nameE ); | 58 | lay->addWidget( nameE ); |
59 | lab = new QLabel( i18n("Local ical (*.ics) file:"), this ); | 59 | lab = new QLabel( i18n("Local ical (*.ics) file:"), this ); |
60 | lay->addWidget( lab ); | 60 | lay->addWidget( lab ); |
61 | url = new KURLRequester ( this ); | 61 | url = new KURLRequester ( this ); |
62 | lay->addWidget( url ); | 62 | lay->addWidget( url ); |
63 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 63 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
64 | lay->addWidget( ok ); | 64 | lay->addWidget( ok ); |
65 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 65 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
66 | lay->addWidget( cancel ); | 66 | lay->addWidget( cancel ); |
67 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 67 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
68 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 68 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
69 | resize( 200, 200 ); | 69 | //resize( 200, 200 ); |
70 | } | 70 | } |
71 | 71 | ||
72 | QString calName() { return nameE->text(); } | 72 | QString calName() { return nameE->text(); } |
73 | QString calFileName() { return url->url(); } | 73 | QString calFileName() { return url->url(); } |
74 | private: | 74 | private: |
75 | KLineEdit* nameE; | 75 | KLineEdit* nameE; |
76 | KURLRequester *url; | 76 | KURLRequester *url; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | 79 | ||
80 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, | 80 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, |
81 | const char* name,WFlags fl ) | 81 | const char* name,WFlags fl ) |
82 | : KOFilterView_base(parent,name,fl) | 82 | : KOFilterView_base(parent,name,fl) |
83 | { | 83 | { |
84 | mFilters = filterList; | 84 | mFilters = filterList; |
85 | 85 | ||
86 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); | 86 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); |
87 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); | 87 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); |
88 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); | 88 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); |
89 | } | 89 | } |
90 | 90 | ||
91 | KOFilterView::~KOFilterView() | 91 | KOFilterView::~KOFilterView() |
92 | { | 92 | { |
93 | // no need to delete child widgets, Qt does it all for us | 93 | // no need to delete child widgets, Qt does it all for us |
94 | } | 94 | } |
95 | 95 | ||
96 | bool KOFilterView::filtersEnabled() | 96 | bool KOFilterView::filtersEnabled() |
97 | { | 97 | { |
98 | return mEnabledCheck->isChecked(); | 98 | return mEnabledCheck->isChecked(); |
99 | } | 99 | } |
100 | 100 | ||
101 | void KOFilterView::setFiltersEnabled(bool set) | 101 | void KOFilterView::setFiltersEnabled(bool set) |
102 | { | 102 | { |
103 | mEnabledCheck->setChecked(set); | 103 | mEnabledCheck->setChecked(set); |
104 | emit filterChanged(); | 104 | emit filterChanged(); |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | void KOFilterView::updateFilters() | 108 | void KOFilterView::updateFilters() |
109 | { | 109 | { |
110 | mSelectionCombo->clear(); | 110 | mSelectionCombo->clear(); |
111 | 111 | ||
112 | CalFilter *filter = mFilters->first(); | 112 | CalFilter *filter = mFilters->first(); |
113 | while(filter) { | 113 | while(filter) { |
114 | mSelectionCombo->insertItem(filter->name()); | 114 | mSelectionCombo->insertItem(filter->name()); |
115 | filter = mFilters->next(); | 115 | filter = mFilters->next(); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | CalFilter *KOFilterView::selectedFilter() | 119 | CalFilter *KOFilterView::selectedFilter() |
120 | { | 120 | { |
121 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | 121 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); |
122 | return f; | 122 | return f; |
123 | } | 123 | } |
124 | 124 | ||
125 | void KOFilterView::setSelectedFilter(QString filterName) | 125 | void KOFilterView::setSelectedFilter(QString filterName) |
126 | { | 126 | { |
127 | int filter_num = mSelectionCombo->count(); | 127 | int filter_num = mSelectionCombo->count(); |
128 | int i; | 128 | int i; |
129 | for (i=0;i<filter_num;i++) { | 129 | for (i=0;i<filter_num;i++) { |
130 | if (mSelectionCombo->text(i)==filterName) | 130 | if (mSelectionCombo->text(i)==filterName) |
131 | mSelectionCombo->setCurrentItem(i); | 131 | mSelectionCombo->setCurrentItem(i); |
132 | } | 132 | } |
133 | emit filterChanged(); | 133 | emit filterChanged(); |
134 | } | 134 | } |
135 | void KOFilterView::setSelectedFilter( int fil ) | 135 | void KOFilterView::setSelectedFilter( int fil ) |
136 | { | 136 | { |
137 | if ( fil >= mSelectionCombo->count() ) | 137 | if ( fil >= mSelectionCombo->count() ) |
138 | return; | 138 | return; |
139 | mSelectionCombo->setCurrentItem( fil ); | 139 | mSelectionCombo->setCurrentItem( fil ); |
140 | emit filterChanged(); | 140 | emit filterChanged(); |
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | 144 | ||
145 | KOCalEditView::KOCalEditView(QWidget* parent, | 145 | KOCalEditView::KOCalEditView(QWidget* parent, |
146 | const char* name ) | 146 | const char* name ) |
147 | : QWidget(parent,name) | 147 | : QWidget(parent,name) |
148 | { | 148 | { |
149 | mw = 0; | 149 | mw = 0; |
150 | ml = new QVBoxLayout ( this ); | 150 | ml = new QVBoxLayout ( this ); |
151 | } | 151 | } |
152 | 152 | ||
153 | KOCalEditView::~KOCalEditView() | 153 | KOCalEditView::~KOCalEditView() |
154 | { | 154 | { |
155 | // no need to delete child widgets, Qt does it all for us | 155 | // no need to delete child widgets, Qt does it all for us |
156 | } | 156 | } |
157 | void KOCalEditView::selectCal(int id ,bool b) | 157 | void KOCalEditView::selectCal(int id ,bool b) |
158 | { | 158 | { |
159 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; | 159 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; |
160 | emit calendarEnabled ( id, b ); | 160 | emit calendarEnabled ( id, b ); |
161 | 161 | ||
162 | } | 162 | } |
163 | void KOCalEditView::selectStdCal( int id, bool b ) | 163 | void KOCalEditView::selectStdCal( int id, bool b ) |
164 | { | 164 | { |
165 | 165 | ||
166 | if ( !b ) { | 166 | if ( !b ) { |
167 | KOCalCheckButton* it = (KOCalCheckButton*) sender(); | 167 | KOCalCheckButton* it = (KOCalCheckButton*) sender(); |
168 | if ( it ) { | 168 | if ( it ) { |
169 | it->blockSignals( true ); | 169 | it->blockSignals( true ); |
170 | it->setChecked( true ); | 170 | it->setChecked( true ); |
171 | it->blockSignals( false ); | 171 | it->blockSignals( false ); |
172 | return; | 172 | return; |
173 | } | 173 | } |
174 | return; | 174 | return; |
175 | } | 175 | } |
176 | KOCalCheckButton* sen = (KOCalCheckButton*) sender(); | 176 | KOCalCheckButton* sen = (KOCalCheckButton*) sender(); |
177 | KOCalCheckButton* it = mStdandardB.first(); | 177 | KOCalCheckButton* it = mStdandardB.first(); |
178 | while ( it ) { | 178 | while ( it ) { |
179 | if ( it->isChecked() ) { | 179 | if ( it->isChecked() ) { |
180 | if ( it != sen ) { | 180 | if ( it != sen ) { |
181 | it->blockSignals( true ); | 181 | it->blockSignals( true ); |
182 | it->setChecked( false ); | 182 | it->setChecked( false ); |
183 | it->blockSignals( false ); | 183 | it->blockSignals( false ); |
184 | break; | 184 | break; |
185 | } | 185 | } |
186 | } | 186 | } |
187 | it = mStdandardB.next(); | 187 | it = mStdandardB.next(); |
188 | } | 188 | } |
189 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 189 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
190 | while ( kkf ) { | 190 | while ( kkf ) { |
191 | kkf->isStandard = false; | 191 | kkf->isStandard = false; |
192 | kkf = KOPrefs::instance()->mCalendars.next(); | 192 | kkf = KOPrefs::instance()->mCalendars.next(); |
193 | } | 193 | } |
194 | KOPrefs::instance()->getCalendar( id )->isStandard = true; | 194 | KOPrefs::instance()->getCalendar( id )->isStandard = true; |
195 | emit setCalendarDefault ( id ); | 195 | emit setCalendarDefault ( id ); |
196 | } | 196 | } |
197 | 197 | ||
198 | void KOCalEditView::selectCalAlarm(int id ,bool b ) | 198 | void KOCalEditView::selectCalAlarm(int id ,bool b ) |
199 | { | 199 | { |
200 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; | 200 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; |
201 | emit alarmEnabled ( id , b ); | 201 | emit alarmEnabled ( id , b ); |
202 | } | 202 | } |
203 | void KOCalEditView::selectReadOnly(int id ,bool b ) | 203 | void KOCalEditView::selectReadOnly(int id ,bool b ) |
204 | { | 204 | { |
205 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; | 205 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; |
206 | emit calendarReadonly ( id , b ); | 206 | emit calendarReadonly ( id , b ); |
207 | 207 | ||
208 | } | 208 | } |
209 | void KOCalEditView::setColor( const QColor& c, int id ) | 209 | void KOCalEditView::setColor( const QColor& c, int id ) |
210 | { | 210 | { |
211 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; | 211 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; |
212 | } | 212 | } |
213 | void KOCalEditView::deleteCal( int id ) | 213 | void KOCalEditView::deleteCal( int id ) |
214 | { | 214 | { |
215 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 215 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
216 | QString name = kkf->mName; | 216 | QString name = kkf->mName; |
217 | QString file = kkf->mFileName; | 217 | QString file = kkf->mFileName; |
218 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; | 218 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; |
219 | emit removeCalendar ( id ); | 219 | emit removeCalendar ( id ); |
220 | KOPrefs::instance()->mCalendars.remove ( kkf ); | 220 | KOPrefs::instance()->mCalendars.remove ( kkf ); |
221 | readConfig(); | 221 | readConfig(); |
222 | } | 222 | } |
223 | void KOCalEditView::infoCal( int id ) | 223 | void KOCalEditView::infoCal( int id ) |
224 | { | 224 | { |
225 | QString name = KOPrefs::instance()->getCalendar( id )->mName; | 225 | QString name = KOPrefs::instance()->getCalendar( id )->mName; |
226 | QString file = KOPrefs::instance()->getCalendar( id )->mFileName; | 226 | QString file = KOPrefs::instance()->getCalendar( id )->mFileName; |
227 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); | 227 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); |
228 | } | 228 | } |
229 | void KOCalEditView::readConfig() | 229 | void KOCalEditView::readConfig() |
230 | { | 230 | { |
231 | 231 | ||
232 | mStdandardB.clear(); | 232 | mStdandardB.clear(); |
233 | mEnabledB.clear(); | 233 | mEnabledB.clear(); |
234 | mAlarmB.clear(); | 234 | mAlarmB.clear(); |
235 | mROB.clear(); | 235 | mROB.clear(); |
236 | 236 | ||
237 | if ( mw ) delete mw; | 237 | if ( mw ) delete mw; |
238 | mw = new QWidget ( this ); | 238 | mw = new QWidget ( this ); |
239 | ml->addWidget ( mw ); | 239 | ml->addWidget ( mw ); |
240 | 240 | ||
241 | mainLayout = new QGridLayout ( mw , 2, 8 ); | 241 | mainLayout = new QGridLayout ( mw , 2, 8 ); |
242 | //mainLayout->setSpacing( 3 ); | 242 | //mainLayout->setSpacing( 3 ); |
243 | QPushButton * addBut = new QPushButton ( mw ); | 243 | QPushButton * addBut = new QPushButton ( mw ); |
244 | mainLayout->addWidget( addBut,0,0 ); | 244 | mainLayout->addWidget( addBut,0,0 ); |
245 | addBut->setPixmap ( SmallIcon("plus")); | 245 | addBut->setPixmap ( SmallIcon("plus")); |
246 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); | 246 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); |
247 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 247 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
248 | 248 | ||
249 | addBut = new QPushButton ( mw ); | 249 | addBut = new QPushButton ( mw ); |
250 | mainLayout->addWidget( addBut,0,1 ); | 250 | mainLayout->addWidget( addBut,0,1 ); |
251 | addBut->setPixmap ( SmallIcon("eye")); | 251 | addBut->setPixmap ( SmallIcon("eye")); |
252 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); | 252 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); |
253 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 253 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
254 | 254 | ||
255 | QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw ); | 255 | QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw ); |
256 | mainLayout->addWidget( lab,0,2 ); | 256 | mainLayout->addWidget( lab,0,2 ); |
257 | 257 | ||
258 | addBut = new QPushButton ( mw ); | 258 | addBut = new QPushButton ( mw ); |
259 | mainLayout->addWidget( addBut,0,3 ); | 259 | mainLayout->addWidget( addBut,0,3 ); |
260 | addBut->setPixmap ( SmallIcon("bell")); | 260 | addBut->setPixmap ( SmallIcon("bell")); |
261 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); | 261 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 95e1607..f05ada5 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -119,385 +119,385 @@ class KOex2phonePrefs : public QDialog | |||
119 | resize( 220, 240 ); | 119 | resize( 220, 240 ); |
120 | qApp->processEvents(); | 120 | qApp->processEvents(); |
121 | int dw = QApplication::desktop()->width(); | 121 | int dw = QApplication::desktop()->width(); |
122 | int dh = QApplication::desktop()->height(); | 122 | int dh = QApplication::desktop()->height(); |
123 | move( (dw-width())/2, (dh - height() )/2 ); | 123 | move( (dw-width())/2, (dh - height() )/2 ); |
124 | } | 124 | } |
125 | 125 | ||
126 | public: | 126 | public: |
127 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 127 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
128 | QCheckBox* mWriteBackFuture; | 128 | QCheckBox* mWriteBackFuture; |
129 | QSpinBox* mWriteBackFutureWeeks; | 129 | QSpinBox* mWriteBackFutureWeeks; |
130 | }; | 130 | }; |
131 | 131 | ||
132 | int globalFlagBlockStartup; | 132 | int globalFlagBlockStartup; |
133 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 133 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
134 | QMainWindow( parent, name ) | 134 | QMainWindow( parent, name ) |
135 | { | 135 | { |
136 | 136 | ||
137 | mClosed = false; | 137 | mClosed = false; |
138 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 138 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
139 | QString confFile = locateLocal("config","korganizerrc"); | 139 | QString confFile = locateLocal("config","korganizerrc"); |
140 | QFileInfo finf ( confFile ); | 140 | QFileInfo finf ( confFile ); |
141 | bool showWarning = !finf.exists(); | 141 | bool showWarning = !finf.exists(); |
142 | setIcon(SmallIcon( "ko24" ) ); | 142 | setIcon(SmallIcon( "ko24" ) ); |
143 | mBlockAtStartup = true; | 143 | mBlockAtStartup = true; |
144 | mFlagKeyPressed = false; | 144 | mFlagKeyPressed = false; |
145 | setCaption("KO/Pi"); | 145 | setCaption("KO/Pi"); |
146 | KOPrefs *p = KOPrefs::instance(); | 146 | KOPrefs *p = KOPrefs::instance(); |
147 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 147 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
148 | p->mCurrentDisplayedView = 0; | 148 | p->mCurrentDisplayedView = 0; |
149 | if ( p->mHourSize > 22 ) | 149 | if ( p->mHourSize > 22 ) |
150 | p->mHourSize = 22; | 150 | p->mHourSize = 22; |
151 | QMainWindow::ToolBarDock tbd; | 151 | QMainWindow::ToolBarDock tbd; |
152 | if ( p->mToolBarHor ) { | 152 | if ( p->mToolBarHor ) { |
153 | if ( p->mToolBarUp ) | 153 | if ( p->mToolBarUp ) |
154 | tbd = Bottom; | 154 | tbd = Bottom; |
155 | else | 155 | else |
156 | tbd = Top; | 156 | tbd = Top; |
157 | } | 157 | } |
158 | else { | 158 | else { |
159 | if ( p->mToolBarUp ) | 159 | if ( p->mToolBarUp ) |
160 | tbd = Right; | 160 | tbd = Right; |
161 | else | 161 | else |
162 | tbd = Left; | 162 | tbd = Left; |
163 | } | 163 | } |
164 | if ( KOPrefs::instance()->mUseAppColors ) | 164 | if ( KOPrefs::instance()->mUseAppColors ) |
165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
166 | globalFlagBlockStartup = 1; | 166 | globalFlagBlockStartup = 1; |
167 | iconToolBar = new QPEToolBar( this ); | 167 | iconToolBar = new QPEToolBar( this ); |
168 | addToolBar (iconToolBar , tbd ); | 168 | addToolBar (iconToolBar , tbd ); |
169 | 169 | ||
170 | #ifdef DESKTOP_VERSION | 170 | #ifdef DESKTOP_VERSION |
171 | if ( KOPrefs::instance()->mShowIconFilter ) | 171 | if ( KOPrefs::instance()->mShowIconFilter ) |
172 | #else | 172 | #else |
173 | if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) | 173 | if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) |
174 | #endif | 174 | #endif |
175 | 175 | ||
176 | { | 176 | { |
177 | if ( p->mToolBarHorF ) { | 177 | if ( p->mToolBarHorF ) { |
178 | if ( p->mToolBarUpF ) | 178 | if ( p->mToolBarUpF ) |
179 | tbd = Bottom; | 179 | tbd = Bottom; |
180 | else | 180 | else |
181 | tbd = Top; | 181 | tbd = Top; |
182 | } | 182 | } |
183 | else { | 183 | else { |
184 | if ( p->mToolBarUpF ) | 184 | if ( p->mToolBarUpF ) |
185 | tbd = Right; | 185 | tbd = Right; |
186 | else | 186 | else |
187 | tbd = Left; | 187 | tbd = Left; |
188 | } | 188 | } |
189 | filterToolBar = new QPEToolBar ( this ); | 189 | filterToolBar = new QPEToolBar ( this ); |
190 | filterMenubar = new QMenuBar( 0 ); | 190 | filterMenubar = new QMenuBar( 0 ); |
191 | QFontMetrics fm ( filterMenubar->font() ); | 191 | QFontMetrics fm ( filterMenubar->font() ); |
192 | 192 | ||
193 | filterPopupMenu = new QPopupMenu( this ); | 193 | filterPopupMenu = new QPopupMenu( this ); |
194 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); | 194 | filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); |
195 | QString addTest = "A"; | 195 | QString addTest = "A"; |
196 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); | 196 | filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); |
197 | #ifdef DESKTOP_VERSION | 197 | #ifdef DESKTOP_VERSION |
198 | addTest = "AAABBBCCCx"; | 198 | addTest = "AAABBBCCCx"; |
199 | #else | 199 | #else |
200 | addTest = "AAx"; | 200 | addTest = "AAx"; |
201 | #endif | 201 | #endif |
202 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); | 202 | filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); |
203 | addToolBar (filterToolBar , tbd ); | 203 | addToolBar (filterToolBar , tbd ); |
204 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); | 204 | connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); |
205 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); | 205 | connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); |
206 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) | 206 | if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) |
207 | filterToolBar->hide(); | 207 | filterToolBar->hide(); |
208 | } else { | 208 | } else { |
209 | filterToolBar = 0; | 209 | filterToolBar = 0; |
210 | filterMenubar = 0; | 210 | filterMenubar = 0; |
211 | filterPopupMenu = 0; | 211 | filterPopupMenu = 0; |
212 | } | 212 | } |
213 | if ( p->mShowIconOnetoolbar ) { | 213 | if ( p->mShowIconOnetoolbar ) { |
214 | viewToolBar = iconToolBar ; | 214 | viewToolBar = iconToolBar ; |
215 | navigatorToolBar = iconToolBar ; | 215 | navigatorToolBar = iconToolBar ; |
216 | } else { | 216 | } else { |
217 | #ifndef DESKTOP_VERSION | 217 | #ifndef DESKTOP_VERSION |
218 | setToolBarsMovable( false ); | 218 | setToolBarsMovable( false ); |
219 | #endif | 219 | #endif |
220 | if ( p->mToolBarHorV ) { | 220 | if ( p->mToolBarHorV ) { |
221 | if ( p->mToolBarUpV ) | 221 | if ( p->mToolBarUpV ) |
222 | tbd = Bottom; | 222 | tbd = Bottom; |
223 | else | 223 | else |
224 | tbd = Top; | 224 | tbd = Top; |
225 | } | 225 | } |
226 | else { | 226 | else { |
227 | if ( p->mToolBarUpV ) | 227 | if ( p->mToolBarUpV ) |
228 | tbd = Right; | 228 | tbd = Right; |
229 | else | 229 | else |
230 | tbd = Left; | 230 | tbd = Left; |
231 | } | 231 | } |
232 | viewToolBar = new QPEToolBar( this ); | 232 | viewToolBar = new QPEToolBar( this ); |
233 | addToolBar (viewToolBar , tbd ); | 233 | addToolBar (viewToolBar , tbd ); |
234 | if ( p->mToolBarHorN ) { | 234 | if ( p->mToolBarHorN ) { |
235 | if ( p->mToolBarUpN ) | 235 | if ( p->mToolBarUpN ) |
236 | tbd = Bottom; | 236 | tbd = Bottom; |
237 | else | 237 | else |
238 | tbd = Top; | 238 | tbd = Top; |
239 | } | 239 | } |
240 | else { | 240 | else { |
241 | if ( p->mToolBarUpN ) | 241 | if ( p->mToolBarUpN ) |
242 | tbd = Right; | 242 | tbd = Right; |
243 | else | 243 | else |
244 | tbd = Left; | 244 | tbd = Left; |
245 | } | 245 | } |
246 | navigatorToolBar = new QPEToolBar( this ); | 246 | navigatorToolBar = new QPEToolBar( this ); |
247 | addToolBar (navigatorToolBar , tbd ); | 247 | addToolBar (navigatorToolBar , tbd ); |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | 251 | ||
252 | mCalendarModifiedFlag = false; | 252 | mCalendarModifiedFlag = false; |
253 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 253 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
254 | splash->setAlignment ( AlignCenter ); | 254 | splash->setAlignment ( AlignCenter ); |
255 | setCentralWidget( splash ); | 255 | setCentralWidget( splash ); |
256 | #ifndef DESKTOP_VERSION | 256 | #ifndef DESKTOP_VERSION |
257 | showMaximized(); | 257 | showMaximized(); |
258 | #endif | 258 | #endif |
259 | 259 | ||
260 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 260 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
261 | setDefaultPreferences(); | 261 | setDefaultPreferences(); |
262 | mCalendar = new CalendarLocal(); | 262 | mCalendar = new CalendarLocal(); |
263 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 263 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
264 | mView->hide(); | 264 | mView->hide(); |
265 | //mView->resize(splash->size() ); | 265 | //mView->resize(splash->size() ); |
266 | initActions(); | 266 | initActions(); |
267 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | 267 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); |
268 | mSyncManager->setBlockSave(false); | 268 | mSyncManager->setBlockSave(false); |
269 | mView->setSyncManager(mSyncManager); | 269 | mView->setSyncManager(mSyncManager); |
270 | #ifndef DESKTOP_VERSION | 270 | #ifndef DESKTOP_VERSION |
271 | iconToolBar->show(); | 271 | iconToolBar->show(); |
272 | qApp->processEvents(); | 272 | qApp->processEvents(); |
273 | #endif | 273 | #endif |
274 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 274 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
275 | int vh = height() ; | 275 | int vh = height() ; |
276 | int vw = width(); | 276 | int vw = width(); |
277 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 277 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
278 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 278 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
279 | vh -= iconToolBar->height(); | 279 | vh -= iconToolBar->height(); |
280 | } else { | 280 | } else { |
281 | vw -= iconToolBar->height(); | 281 | vw -= iconToolBar->height(); |
282 | } | 282 | } |
283 | //mView->setMaximumSize( splash->size() ); | 283 | //mView->setMaximumSize( splash->size() ); |
284 | //mView->resize( splash->size() ); | 284 | //mView->resize( splash->size() ); |
285 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 285 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
286 | mView->readSettings(); | 286 | mView->readSettings(); |
287 | bool newFile = false; | 287 | bool newFile = false; |
288 | if( !QFile::exists( defaultFileName() ) ) { | 288 | if( !QFile::exists( defaultFileName() ) ) { |
289 | QFileInfo finfo ( defaultFileName() ); | 289 | QFileInfo finfo ( defaultFileName() ); |
290 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 290 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
291 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 291 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
292 | finfo.setFile( oldFile ); | 292 | finfo.setFile( oldFile ); |
293 | if (finfo.exists() ) { | 293 | if (finfo.exists() ) { |
294 | KMessageBox::information( this, message); | 294 | KMessageBox::information( this, message); |
295 | mView->openCalendar( oldFile ); | 295 | mView->openCalendar( oldFile ); |
296 | qApp->processEvents(); | 296 | qApp->processEvents(); |
297 | } else { | 297 | } else { |
298 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 298 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
299 | finfo.setFile( oldFile ); | 299 | finfo.setFile( oldFile ); |
300 | if (finfo.exists() ) { | 300 | if (finfo.exists() ) { |
301 | KMessageBox::information( this, message); | 301 | KMessageBox::information( this, message); |
302 | mView->openCalendar( oldFile ); | 302 | mView->openCalendar( oldFile ); |
303 | qApp->processEvents(); | 303 | qApp->processEvents(); |
304 | } | 304 | } |
305 | } | 305 | } |
306 | mView->saveCalendar( defaultFileName() ); | 306 | mView->saveCalendar( defaultFileName() ); |
307 | newFile = true; | 307 | newFile = true; |
308 | } | 308 | } |
309 | 309 | ||
310 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 310 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
311 | mView->openCalendar( defaultFileName() ); | 311 | mView->loadCalendars(); |
312 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 312 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
313 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 313 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
314 | 314 | ||
315 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 315 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
316 | KOPrefs::instance()->setAllDefaults(); | 316 | KOPrefs::instance()->setAllDefaults(); |
317 | int count = mView->addCategories(); | 317 | int count = mView->addCategories(); |
318 | } | 318 | } |
319 | processIncidenceSelection( 0 ); | 319 | processIncidenceSelection( 0 ); |
320 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 320 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
321 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 321 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
322 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 322 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
323 | SLOT( slotModifiedChanged( bool ) ) ); | 323 | SLOT( slotModifiedChanged( bool ) ) ); |
324 | 324 | ||
325 | 325 | ||
326 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 326 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
327 | SLOT( disableBR(bool) ) ); | 327 | SLOT( disableBR(bool) ) ); |
328 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 328 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
329 | mView->setModified( false ); | 329 | mView->setModified( false ); |
330 | mBlockAtStartup = false; | 330 | mBlockAtStartup = false; |
331 | mView->setModified( false ); | 331 | mView->setModified( false ); |
332 | setCentralWidget( mView ); | 332 | setCentralWidget( mView ); |
333 | globalFlagBlockStartup = 0; | 333 | globalFlagBlockStartup = 0; |
334 | mView->show(); | 334 | mView->show(); |
335 | delete splash; | 335 | delete splash; |
336 | if ( newFile ) | 336 | if ( newFile ) |
337 | mView->updateConfig(); | 337 | mView->updateConfig(); |
338 | // qApp->processEvents(); | 338 | // qApp->processEvents(); |
339 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 339 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
340 | //fillSyncMenu(); | 340 | //fillSyncMenu(); |
341 | 341 | ||
342 | 342 | ||
343 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 343 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
344 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); | 344 | connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); |
345 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 345 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
346 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 346 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
347 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 347 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
348 | mSyncManager->setDefaultFileName( sentSyncFile()); | 348 | mSyncManager->setDefaultFileName( sentSyncFile()); |
349 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 349 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
350 | mSyncManager->fillSyncMenu(); | 350 | mSyncManager->fillSyncMenu(); |
351 | 351 | ||
352 | 352 | ||
353 | 353 | ||
354 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 354 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
355 | if ( showWarning ) { | 355 | if ( showWarning ) { |
356 | KMessageBox::information( this, | 356 | KMessageBox::information( this, |
357 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 357 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
358 | qApp->processEvents(); | 358 | qApp->processEvents(); |
359 | mView->dialogManager()->showSyncOptions(); | 359 | mView->dialogManager()->showSyncOptions(); |
360 | } | 360 | } |
361 | 361 | ||
362 | //US listen for result adressed from Ka/Pi | 362 | //US listen for result adressed from Ka/Pi |
363 | #ifndef DESKTOP_VERSION | 363 | #ifndef DESKTOP_VERSION |
364 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 364 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
365 | #endif | 365 | #endif |
366 | #ifndef DESKTOP_VERSION | 366 | #ifndef DESKTOP_VERSION |
367 | infrared = 0; | 367 | infrared = 0; |
368 | #endif | 368 | #endif |
369 | updateFilterToolbar(); | 369 | updateFilterToolbar(); |
370 | updateWeek( mView->startDate() ); | 370 | updateWeek( mView->startDate() ); |
371 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 371 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
372 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 372 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
373 | mBRdisabled = false; | 373 | mBRdisabled = false; |
374 | //toggleBeamReceive(); | 374 | //toggleBeamReceive(); |
375 | int tiint= 3000; | 375 | int tiint= 3000; |
376 | #ifndef DESKTOP_VERSION | 376 | #ifndef DESKTOP_VERSION |
377 | tiint = 5000; | 377 | tiint = 5000; |
378 | #endif | 378 | #endif |
379 | QTimer::singleShot( tiint, mView, SLOT ( checkAlarms() )); | 379 | QTimer::singleShot( tiint, mView, SLOT ( checkAlarms() )); |
380 | } | 380 | } |
381 | MainWindow::~MainWindow() | 381 | MainWindow::~MainWindow() |
382 | { | 382 | { |
383 | //qDebug("MainWindow::~MainWindow() "); | 383 | //qDebug("MainWindow::~MainWindow() "); |
384 | //save toolbar location | 384 | //save toolbar location |
385 | delete mCalendar; | 385 | delete mCalendar; |
386 | delete mSyncManager; | 386 | delete mSyncManager; |
387 | #ifndef DESKTOP_VERSION | 387 | #ifndef DESKTOP_VERSION |
388 | if ( infrared ) | 388 | if ( infrared ) |
389 | delete infrared; | 389 | delete infrared; |
390 | #endif | 390 | #endif |
391 | 391 | ||
392 | 392 | ||
393 | } | 393 | } |
394 | 394 | ||
395 | void MainWindow::disableBR(bool b) | 395 | void MainWindow::disableBR(bool b) |
396 | { | 396 | { |
397 | #ifndef DESKTOP_VERSION | 397 | #ifndef DESKTOP_VERSION |
398 | if ( b ) { | 398 | if ( b ) { |
399 | if ( infrared ) { | 399 | if ( infrared ) { |
400 | toggleBeamReceive(); | 400 | toggleBeamReceive(); |
401 | mBRdisabled = true; | 401 | mBRdisabled = true; |
402 | } | 402 | } |
403 | mBRdisabled = true; | 403 | mBRdisabled = true; |
404 | } else { | 404 | } else { |
405 | if ( mBRdisabled ) { | 405 | if ( mBRdisabled ) { |
406 | mBRdisabled = false; | 406 | mBRdisabled = false; |
407 | //makes no sense,because other cal ap is probably running | 407 | //makes no sense,because other cal ap is probably running |
408 | // toggleBeamReceive(); | 408 | // toggleBeamReceive(); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | #endif | 411 | #endif |
412 | 412 | ||
413 | } | 413 | } |
414 | bool MainWindow::beamReceiveEnabled() | 414 | bool MainWindow::beamReceiveEnabled() |
415 | { | 415 | { |
416 | #ifndef DESKTOP_VERSION | 416 | #ifndef DESKTOP_VERSION |
417 | return ( infrared != 0 ); | 417 | return ( infrared != 0 ); |
418 | #endif | 418 | #endif |
419 | return false; | 419 | return false; |
420 | } | 420 | } |
421 | 421 | ||
422 | void MainWindow::toggleBeamReceive() | 422 | void MainWindow::toggleBeamReceive() |
423 | { | 423 | { |
424 | if ( mBRdisabled ) | 424 | if ( mBRdisabled ) |
425 | return; | 425 | return; |
426 | #ifndef DESKTOP_VERSION | 426 | #ifndef DESKTOP_VERSION |
427 | if ( infrared ) { | 427 | if ( infrared ) { |
428 | qDebug("KO: Disable BeamReceive "); | 428 | qDebug("KO: Disable BeamReceive "); |
429 | delete infrared; | 429 | delete infrared; |
430 | infrared = 0; | 430 | infrared = 0; |
431 | brAction->setOn(false); | 431 | brAction->setOn(false); |
432 | return; | 432 | return; |
433 | } | 433 | } |
434 | qDebug("KO: Enable BeamReceive "); | 434 | qDebug("KO: Enable BeamReceive "); |
435 | brAction->setOn(true); | 435 | brAction->setOn(true); |
436 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; | 436 | infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; |
437 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); | 437 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); |
438 | #endif | 438 | #endif |
439 | } | 439 | } |
440 | void MainWindow::showMaximized () | 440 | void MainWindow::showMaximized () |
441 | { | 441 | { |
442 | #ifndef DESKTOP_VERSION | 442 | #ifndef DESKTOP_VERSION |
443 | if ( ! globalFlagBlockStartup ) | 443 | if ( ! globalFlagBlockStartup ) |
444 | if ( mClosed ) | 444 | if ( mClosed ) |
445 | mView->goToday(); | 445 | mView->goToday(); |
446 | #endif | 446 | #endif |
447 | QWidget::showMaximized () ; | 447 | QWidget::showMaximized () ; |
448 | mClosed = false; | 448 | mClosed = false; |
449 | } | 449 | } |
450 | void MainWindow::closeEvent( QCloseEvent* ce ) | 450 | void MainWindow::closeEvent( QCloseEvent* ce ) |
451 | { | 451 | { |
452 | 452 | ||
453 | 453 | ||
454 | 454 | ||
455 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 455 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
456 | saveOnClose(); | 456 | saveOnClose(); |
457 | mClosed = true; | 457 | mClosed = true; |
458 | ce->accept(); | 458 | ce->accept(); |
459 | return; | 459 | return; |
460 | 460 | ||
461 | } | 461 | } |
462 | 462 | ||
463 | switch( QMessageBox::information( this, "KO/Pi", | 463 | switch( QMessageBox::information( this, "KO/Pi", |
464 | i18n("Do you really want\nto close KO/Pi?"), | 464 | i18n("Do you really want\nto close KO/Pi?"), |
465 | i18n("Close"), i18n("No"), | 465 | i18n("Close"), i18n("No"), |
466 | 0, 0 ) ) { | 466 | 0, 0 ) ) { |
467 | case 0: | 467 | case 0: |
468 | saveOnClose(); | 468 | saveOnClose(); |
469 | mClosed = true; | 469 | mClosed = true; |
470 | ce->accept(); | 470 | ce->accept(); |
471 | break; | 471 | break; |
472 | case 1: | 472 | case 1: |
473 | ce->ignore(); | 473 | ce->ignore(); |
474 | break; | 474 | break; |
475 | case 2: | 475 | case 2: |
476 | 476 | ||
477 | default: | 477 | default: |
478 | break; | 478 | break; |
479 | } | 479 | } |
480 | 480 | ||
481 | 481 | ||
482 | } | 482 | } |
483 | 483 | ||
484 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 484 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
485 | { | 485 | { |
486 | QDataStream stream( data, IO_ReadOnly ); | 486 | QDataStream stream( data, IO_ReadOnly ); |
487 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 487 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
488 | //QString datamess; | 488 | //QString datamess; |
489 | //qDebug("message "); | 489 | //qDebug("message "); |
490 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 490 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
491 | 491 | ||
492 | if ( cmsg == "setDocument(QString)" ) { | 492 | if ( cmsg == "setDocument(QString)" ) { |
493 | QDataStream stream( data, IO_ReadOnly ); | 493 | QDataStream stream( data, IO_ReadOnly ); |
494 | QString fileName; | 494 | QString fileName; |
495 | stream >> fileName; | 495 | stream >> fileName; |
496 | //qDebug("filename %s ", fileName.latin1()); | 496 | //qDebug("filename %s ", fileName.latin1()); |
497 | showMaximized(); | 497 | showMaximized(); |
498 | raise(); | 498 | raise(); |
499 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; | 499 | KOPrefs::instance()->mLastSyncedLocalFile = fileName ; |
500 | mSyncManager->slotSyncMenu( 1002 ); | 500 | mSyncManager->slotSyncMenu( 1002 ); |
501 | return; | 501 | return; |
502 | } | 502 | } |
503 | 503 | ||
@@ -1668,385 +1668,385 @@ void MainWindow::processIncidenceSelection( Incidence *incidence ) | |||
1668 | } | 1668 | } |
1669 | 1669 | ||
1670 | void MainWindow::enableIncidenceActions( bool enabled ) | 1670 | void MainWindow::enableIncidenceActions( bool enabled ) |
1671 | { | 1671 | { |
1672 | mShowAction->setEnabled( enabled ); | 1672 | mShowAction->setEnabled( enabled ); |
1673 | mEditAction->setEnabled( enabled ); | 1673 | mEditAction->setEnabled( enabled ); |
1674 | mDeleteAction->setEnabled( enabled ); | 1674 | mDeleteAction->setEnabled( enabled ); |
1675 | 1675 | ||
1676 | mCloneAction->setEnabled( enabled ); | 1676 | mCloneAction->setEnabled( enabled ); |
1677 | mMoveAction->setEnabled( enabled ); | 1677 | mMoveAction->setEnabled( enabled ); |
1678 | mBeamAction->setEnabled( enabled ); | 1678 | mBeamAction->setEnabled( enabled ); |
1679 | mCancelAction->setEnabled( enabled ); | 1679 | mCancelAction->setEnabled( enabled ); |
1680 | } | 1680 | } |
1681 | 1681 | ||
1682 | void MainWindow::importOL() | 1682 | void MainWindow::importOL() |
1683 | { | 1683 | { |
1684 | #ifdef _OL_IMPORT_ | 1684 | #ifdef _OL_IMPORT_ |
1685 | mView->clearAllViews(); | 1685 | mView->clearAllViews(); |
1686 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1686 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1687 | id->exec(); | 1687 | id->exec(); |
1688 | delete id; | 1688 | delete id; |
1689 | mView->calendar()->checkAlarmForIncidence( 0, true ); | 1689 | mView->calendar()->checkAlarmForIncidence( 0, true ); |
1690 | mView->updateView(); | 1690 | mView->updateView(); |
1691 | #endif | 1691 | #endif |
1692 | } | 1692 | } |
1693 | void MainWindow::importBday() | 1693 | void MainWindow::importBday() |
1694 | { | 1694 | { |
1695 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1695 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1696 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1696 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1697 | i18n("Import!"), i18n("Cancel"), 0, | 1697 | i18n("Import!"), i18n("Cancel"), 0, |
1698 | 0, 1 ); | 1698 | 0, 1 ); |
1699 | if ( result == 0 ) { | 1699 | if ( result == 0 ) { |
1700 | mView->importBday(); | 1700 | mView->importBday(); |
1701 | 1701 | ||
1702 | } | 1702 | } |
1703 | 1703 | ||
1704 | 1704 | ||
1705 | } | 1705 | } |
1706 | void MainWindow::importQtopia() | 1706 | void MainWindow::importQtopia() |
1707 | { | 1707 | { |
1708 | //#ifndef DESKTOP_VERSION | 1708 | //#ifndef DESKTOP_VERSION |
1709 | QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); | 1709 | QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); |
1710 | #ifdef DESKTOP_VERSION | 1710 | #ifdef DESKTOP_VERSION |
1711 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); | 1711 | mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); |
1712 | #endif | 1712 | #endif |
1713 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, | 1713 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, |
1714 | i18n("Import!"), i18n("Cancel"), 0, | 1714 | i18n("Import!"), i18n("Cancel"), 0, |
1715 | 0, 1 ); | 1715 | 0, 1 ); |
1716 | if ( result == 0 ) { | 1716 | if ( result == 0 ) { |
1717 | #ifndef DESKTOP_VERSION | 1717 | #ifndef DESKTOP_VERSION |
1718 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1718 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1719 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1719 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1720 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1720 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1721 | #else | 1721 | #else |
1722 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; | 1722 | QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; |
1723 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; | 1723 | QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; |
1724 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; | 1724 | QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; |
1725 | #endif | 1725 | #endif |
1726 | mView->importQtopia( categories, datebook, todolist ); | 1726 | mView->importQtopia( categories, datebook, todolist ); |
1727 | } | 1727 | } |
1728 | mView->calendar()->reInitAlarmSettings(); | 1728 | mView->calendar()->reInitAlarmSettings(); |
1729 | #if 0 | 1729 | #if 0 |
1730 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1730 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1731 | i18n("Not supported \non desktop!\n"), | 1731 | i18n("Not supported \non desktop!\n"), |
1732 | i18n("Ok"), i18n("Cancel"), 0, | 1732 | i18n("Ok"), i18n("Cancel"), 0, |
1733 | 0, 1 ); | 1733 | 0, 1 ); |
1734 | 1734 | ||
1735 | #endif | 1735 | #endif |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | void MainWindow::saveOnClose() | 1738 | void MainWindow::saveOnClose() |
1739 | { | 1739 | { |
1740 | KOPrefs *p = KOPrefs::instance(); | 1740 | KOPrefs *p = KOPrefs::instance(); |
1741 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1741 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1742 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); | 1742 | p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); |
1743 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); | 1743 | p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); |
1744 | if ( filterToolBar ) { | 1744 | if ( filterToolBar ) { |
1745 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); | 1745 | p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); |
1746 | } | 1746 | } |
1747 | #ifdef DESKTOP_VERSION | 1747 | #ifdef DESKTOP_VERSION |
1748 | 1748 | ||
1749 | QPoint myP; | 1749 | QPoint myP; |
1750 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1750 | myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1751 | if ( p->mToolBarHor ) | 1751 | if ( p->mToolBarHor ) |
1752 | p->mToolBarUp = myP.y() > height()/2; | 1752 | p->mToolBarUp = myP.y() > height()/2; |
1753 | else | 1753 | else |
1754 | p->mToolBarUp = myP.x() > width()/2; | 1754 | p->mToolBarUp = myP.x() > width()/2; |
1755 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1755 | myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1756 | if ( p->mToolBarHorV ) | 1756 | if ( p->mToolBarHorV ) |
1757 | p->mToolBarUpV = myP.y() > height()/2; | 1757 | p->mToolBarUpV = myP.y() > height()/2; |
1758 | else | 1758 | else |
1759 | p->mToolBarUpV = myP.x() > width()/2 ; | 1759 | p->mToolBarUpV = myP.x() > width()/2 ; |
1760 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1760 | myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1761 | if ( p->mToolBarHorN ) | 1761 | if ( p->mToolBarHorN ) |
1762 | p->mToolBarUpN = myP.y() > height()/2; | 1762 | p->mToolBarUpN = myP.y() > height()/2; |
1763 | else | 1763 | else |
1764 | p->mToolBarUpN = myP.x() > width()/2 ; | 1764 | p->mToolBarUpN = myP.x() > width()/2 ; |
1765 | if ( filterToolBar ) { | 1765 | if ( filterToolBar ) { |
1766 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); | 1766 | myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); |
1767 | if ( p->mToolBarHorF ) | 1767 | if ( p->mToolBarHorF ) |
1768 | p->mToolBarUpF = myP.y() > height()/2; | 1768 | p->mToolBarUpF = myP.y() > height()/2; |
1769 | else | 1769 | else |
1770 | p->mToolBarUpF = myP.x() > width()/2 ; | 1770 | p->mToolBarUpF = myP.x() > width()/2 ; |
1771 | } | 1771 | } |
1772 | #else | 1772 | #else |
1773 | if ( p->mToolBarHor ) | 1773 | if ( p->mToolBarHor ) |
1774 | p->mToolBarUp = iconToolBar->y() > height()/2; | 1774 | p->mToolBarUp = iconToolBar->y() > height()/2; |
1775 | else | 1775 | else |
1776 | p->mToolBarUp = iconToolBar->x() > width()/2; | 1776 | p->mToolBarUp = iconToolBar->x() > width()/2; |
1777 | if ( p->mToolBarHorV ) | 1777 | if ( p->mToolBarHorV ) |
1778 | p->mToolBarUpV = viewToolBar->y() > height()/2; | 1778 | p->mToolBarUpV = viewToolBar->y() > height()/2; |
1779 | else | 1779 | else |
1780 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; | 1780 | p->mToolBarUpV = viewToolBar->x() > width()/2 ; |
1781 | 1781 | ||
1782 | if ( p->mToolBarHorN ) | 1782 | if ( p->mToolBarHorN ) |
1783 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; | 1783 | p->mToolBarUpN = navigatorToolBar->y() > height()/2; |
1784 | else | 1784 | else |
1785 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; | 1785 | p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; |
1786 | if ( filterToolBar ) { | 1786 | if ( filterToolBar ) { |
1787 | if ( p->mToolBarHorF ) | 1787 | if ( p->mToolBarHorF ) |
1788 | p->mToolBarUpF = filterToolBar->y() > height()/2; | 1788 | p->mToolBarUpF = filterToolBar->y() > height()/2; |
1789 | else | 1789 | else |
1790 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; | 1790 | p->mToolBarUpF = filterToolBar->x() > width()/2 ; |
1791 | } | 1791 | } |
1792 | #endif | 1792 | #endif |
1793 | 1793 | ||
1794 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1794 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1795 | save(); | 1795 | save(); |
1796 | mView->writeSettings(); | 1796 | mView->writeSettings(); |
1797 | } | 1797 | } |
1798 | void MainWindow::slotModifiedChanged( bool changed ) | 1798 | void MainWindow::slotModifiedChanged( bool changed ) |
1799 | { | 1799 | { |
1800 | if ( mBlockAtStartup ) | 1800 | if ( mBlockAtStartup ) |
1801 | return; | 1801 | return; |
1802 | 1802 | ||
1803 | int msec; | 1803 | int msec; |
1804 | // we store the changes after 1 minute, | 1804 | // we store the changes after 1 minute, |
1805 | // and for safety reasons after 10 minutes again | 1805 | // and for safety reasons after 10 minutes again |
1806 | if ( !mSyncManager->blockSave() ) | 1806 | if ( !mSyncManager->blockSave() ) |
1807 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1807 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1808 | else | 1808 | else |
1809 | msec = 1000 * 600; | 1809 | msec = 1000 * 600; |
1810 | mSaveTimer.start( msec, true ); // 1 minute | 1810 | mSaveTimer.start( msec, true ); // 1 minute |
1811 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1811 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1812 | mCalendarModifiedFlag = true; | 1812 | mCalendarModifiedFlag = true; |
1813 | } | 1813 | } |
1814 | void MainWindow::saveStopTimer() | 1814 | void MainWindow::saveStopTimer() |
1815 | { | 1815 | { |
1816 | mSaveTimer.stop(); | 1816 | mSaveTimer.stop(); |
1817 | } | 1817 | } |
1818 | void MainWindow::save() | 1818 | void MainWindow::save() |
1819 | { | 1819 | { |
1820 | if ( !mCalendarModifiedFlag ) { | 1820 | if ( !mCalendarModifiedFlag ) { |
1821 | qDebug("KO: Calendar not modified. Nothing saved."); | 1821 | qDebug("KO: Calendar not modified. Nothing saved."); |
1822 | return; | 1822 | return; |
1823 | } | 1823 | } |
1824 | if ( mSyncManager->blockSave() ) | 1824 | if ( mSyncManager->blockSave() ) |
1825 | return; | 1825 | return; |
1826 | mSyncManager->setBlockSave(true); | 1826 | mSyncManager->setBlockSave(true); |
1827 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1827 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1828 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ | 1828 | if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ |
1829 | QDate reference ( 2000,1,1); | 1829 | QDate reference ( 2000,1,1); |
1830 | int daysTo = reference.daysTo ( QDate::currentDate() ); | 1830 | int daysTo = reference.daysTo ( QDate::currentDate() ); |
1831 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { | 1831 | if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { |
1832 | setCaption(i18n("Creating backup ... please wait ..." )); | 1832 | setCaption(i18n("Creating backup ... please wait ..." )); |
1833 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); | 1833 | qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); |
1834 | // we need the file path, the backup dir and the number of bups as param | 1834 | // we need the file path, the backup dir and the number of bups as param |
1835 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; | 1835 | QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; |
1836 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) | 1836 | if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) |
1837 | bupDir = KGlobalSettings::backupDataDir(); | 1837 | bupDir = KGlobalSettings::backupDataDir(); |
1838 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); | 1838 | int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); |
1839 | if ( retval == 0 ) { | 1839 | if ( retval == 0 ) { |
1840 | qDebug("KO: Backup cancelled. Will try again tomorrow "); | 1840 | qDebug("KO: Backup cancelled. Will try again tomorrow "); |
1841 | // retval == 0 : backup skipped for today, try again tomorrow | 1841 | // retval == 0 : backup skipped for today, try again tomorrow |
1842 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; | 1842 | KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; |
1843 | } else if ( retval == 1 ){ | 1843 | } else if ( retval == 1 ){ |
1844 | qDebug("KO: Backup created."); | 1844 | qDebug("KO: Backup created."); |
1845 | // backup ok | 1845 | // backup ok |
1846 | KOPrefs::instance()->mLastBackupDate = daysTo; | 1846 | KOPrefs::instance()->mLastBackupDate = daysTo; |
1847 | 1847 | ||
1848 | } else if ( retval == 2 ){ | 1848 | } else if ( retval == 2 ){ |
1849 | qDebug("KO: Backup globally cancelled."); | 1849 | qDebug("KO: Backup globally cancelled."); |
1850 | // backup globally cancelled | 1850 | // backup globally cancelled |
1851 | KPimGlobalPrefs::instance()->mBackupEnabled = false; | 1851 | KPimGlobalPrefs::instance()->mBackupEnabled = false; |
1852 | } | 1852 | } |
1853 | // retval == 3: do nothing, try again later | 1853 | // retval == 3: do nothing, try again later |
1854 | } | 1854 | } |
1855 | ; // KPimGlobalPrefs::instance()->mLastBackupDate | 1855 | ; // KPimGlobalPrefs::instance()->mLastBackupDate |
1856 | } | 1856 | } |
1857 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1857 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1858 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1858 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1859 | qDebug("KO: Start saving data to file!"); | 1859 | qDebug("KO: Start saving data to file!"); |
1860 | mView->saveCalendar( defaultFileName() ); | 1860 | mView->saveCalendars(); |
1861 | mCalendarModifiedFlag = false; | 1861 | mCalendarModifiedFlag = false; |
1862 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1862 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1863 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1863 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1864 | QString savemes; | 1864 | QString savemes; |
1865 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1865 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1866 | setCaption(savemes); | 1866 | setCaption(savemes); |
1867 | } else | 1867 | } else |
1868 | setCaption(i18n("Saving cancelled!")); | 1868 | setCaption(i18n("Saving cancelled!")); |
1869 | mSyncManager->setBlockSave( false ); | 1869 | mSyncManager->setBlockSave( false ); |
1870 | } | 1870 | } |
1871 | 1871 | ||
1872 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1872 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1873 | { | 1873 | { |
1874 | if ( !e->isAutoRepeat() ) { | 1874 | if ( !e->isAutoRepeat() ) { |
1875 | mFlagKeyPressed = false; | 1875 | mFlagKeyPressed = false; |
1876 | } | 1876 | } |
1877 | } | 1877 | } |
1878 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1878 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1879 | { | 1879 | { |
1880 | qApp->processEvents(); | 1880 | qApp->processEvents(); |
1881 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1881 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1882 | e->ignore(); | 1882 | e->ignore(); |
1883 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1883 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1884 | return; | 1884 | return; |
1885 | } | 1885 | } |
1886 | if (! e->isAutoRepeat() ) | 1886 | if (! e->isAutoRepeat() ) |
1887 | mFlagKeyPressed = true; | 1887 | mFlagKeyPressed = true; |
1888 | KOPrefs *p = KOPrefs::instance(); | 1888 | KOPrefs *p = KOPrefs::instance(); |
1889 | bool showSelectedDates = false; | 1889 | bool showSelectedDates = false; |
1890 | int size; | 1890 | int size; |
1891 | int pro = 0; | 1891 | int pro = 0; |
1892 | //qDebug("MainWindow::keyPressEvent "); | 1892 | //qDebug("MainWindow::keyPressEvent "); |
1893 | switch ( e->key() ) { | 1893 | switch ( e->key() ) { |
1894 | case Qt::Key_Right: | 1894 | case Qt::Key_Right: |
1895 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1895 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1896 | mView->goNextMonth(); | 1896 | mView->goNextMonth(); |
1897 | else | 1897 | else |
1898 | mView->goNext(); | 1898 | mView->goNext(); |
1899 | showSelectedDates = true; | 1899 | showSelectedDates = true; |
1900 | break; | 1900 | break; |
1901 | case Qt::Key_Left: | 1901 | case Qt::Key_Left: |
1902 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1902 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1903 | mView->goPreviousMonth(); | 1903 | mView->goPreviousMonth(); |
1904 | else | 1904 | else |
1905 | mView->goPrevious(); | 1905 | mView->goPrevious(); |
1906 | showSelectedDates = true; | 1906 | showSelectedDates = true; |
1907 | break; | 1907 | break; |
1908 | case Qt::Key_Down: | 1908 | case Qt::Key_Down: |
1909 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1909 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1910 | break; | 1910 | break; |
1911 | case Qt::Key_Up: | 1911 | case Qt::Key_Up: |
1912 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1912 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1913 | break; | 1913 | break; |
1914 | case Qt::Key_K: | 1914 | case Qt::Key_K: |
1915 | mView->viewManager()->showMonthViewWeek(); | 1915 | mView->viewManager()->showMonthViewWeek(); |
1916 | break; | 1916 | break; |
1917 | case Qt::Key_I: | 1917 | case Qt::Key_I: |
1918 | mView->showIncidence(); | 1918 | mView->showIncidence(); |
1919 | break; | 1919 | break; |
1920 | case Qt::Key_Delete: | 1920 | case Qt::Key_Delete: |
1921 | case Qt::Key_Backspace: | 1921 | case Qt::Key_Backspace: |
1922 | mView->deleteIncidence(); | 1922 | mView->deleteIncidence(); |
1923 | break; | 1923 | break; |
1924 | case Qt::Key_D: | 1924 | case Qt::Key_D: |
1925 | mView->viewManager()->showDayView(); | 1925 | mView->viewManager()->showDayView(); |
1926 | showSelectedDates = true; | 1926 | showSelectedDates = true; |
1927 | break; | 1927 | break; |
1928 | case Qt::Key_O: | 1928 | case Qt::Key_O: |
1929 | mView->toggleFilerEnabled( ); | 1929 | mView->toggleFilerEnabled( ); |
1930 | break; | 1930 | break; |
1931 | case Qt::Key_0: | 1931 | case Qt::Key_0: |
1932 | case Qt::Key_1: | 1932 | case Qt::Key_1: |
1933 | case Qt::Key_2: | 1933 | case Qt::Key_2: |
1934 | case Qt::Key_3: | 1934 | case Qt::Key_3: |
1935 | case Qt::Key_4: | 1935 | case Qt::Key_4: |
1936 | case Qt::Key_5: | 1936 | case Qt::Key_5: |
1937 | case Qt::Key_6: | 1937 | case Qt::Key_6: |
1938 | case Qt::Key_7: | 1938 | case Qt::Key_7: |
1939 | case Qt::Key_8: | 1939 | case Qt::Key_8: |
1940 | case Qt::Key_9: | 1940 | case Qt::Key_9: |
1941 | pro = e->key()-48; | 1941 | pro = e->key()-48; |
1942 | if ( pro == 0 ) | 1942 | if ( pro == 0 ) |
1943 | pro = 10; | 1943 | pro = 10; |
1944 | if ( e->state() == Qt::ControlButton) | 1944 | if ( e->state() == Qt::ControlButton) |
1945 | pro += 10; | 1945 | pro += 10; |
1946 | break; | 1946 | break; |
1947 | case Qt::Key_M: | 1947 | case Qt::Key_M: |
1948 | mView->viewManager()->showMonthView(); | 1948 | mView->viewManager()->showMonthView(); |
1949 | showSelectedDates = true; | 1949 | showSelectedDates = true; |
1950 | break; | 1950 | break; |
1951 | case Qt::Key_Insert: | 1951 | case Qt::Key_Insert: |
1952 | mView->newEvent(); | 1952 | mView->newEvent(); |
1953 | break; | 1953 | break; |
1954 | case Qt::Key_S : | 1954 | case Qt::Key_S : |
1955 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1955 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1956 | mView->newSubTodo(); | 1956 | mView->newSubTodo(); |
1957 | else | 1957 | else |
1958 | mView->dialogManager()->showSearchDialog(); | 1958 | mView->dialogManager()->showSearchDialog(); |
1959 | break; | 1959 | break; |
1960 | case Qt::Key_Y : | 1960 | case Qt::Key_Y : |
1961 | case Qt::Key_Z : | 1961 | case Qt::Key_Z : |
1962 | mView->viewManager()->showWorkWeekView(); | 1962 | mView->viewManager()->showWorkWeekView(); |
1963 | showSelectedDates = true; | 1963 | showSelectedDates = true; |
1964 | break; | 1964 | break; |
1965 | case Qt::Key_U : | 1965 | case Qt::Key_U : |
1966 | mView->viewManager()->showWeekView(); | 1966 | mView->viewManager()->showWeekView(); |
1967 | showSelectedDates = true; | 1967 | showSelectedDates = true; |
1968 | break; | 1968 | break; |
1969 | case Qt::Key_H : | 1969 | case Qt::Key_H : |
1970 | keyBindings(); | 1970 | keyBindings(); |
1971 | break; | 1971 | break; |
1972 | case Qt::Key_W: | 1972 | case Qt::Key_W: |
1973 | mView->viewManager()->showWhatsNextView(); | 1973 | mView->viewManager()->showWhatsNextView(); |
1974 | break; | 1974 | break; |
1975 | case Qt::Key_L: | 1975 | case Qt::Key_L: |
1976 | mView->viewManager()->showListView(); | 1976 | mView->viewManager()->showListView(); |
1977 | break; | 1977 | break; |
1978 | case Qt::Key_N: | 1978 | case Qt::Key_N: |
1979 | mView->viewManager()->showNextView(); | 1979 | mView->viewManager()->showNextView(); |
1980 | break; | 1980 | break; |
1981 | case Qt::Key_V: | 1981 | case Qt::Key_V: |
1982 | mView->viewManager()->showTodoView(); | 1982 | mView->viewManager()->showTodoView(); |
1983 | break; | 1983 | break; |
1984 | case Qt::Key_C: | 1984 | case Qt::Key_C: |
1985 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1985 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1986 | break; | 1986 | break; |
1987 | case Qt::Key_P: | 1987 | case Qt::Key_P: |
1988 | mView->showDatePicker( ); | 1988 | mView->showDatePicker( ); |
1989 | break; | 1989 | break; |
1990 | case Qt::Key_F: | 1990 | case Qt::Key_F: |
1991 | mView->editFilters(); | 1991 | mView->editFilters(); |
1992 | break; | 1992 | break; |
1993 | case Qt::Key_R: | 1993 | case Qt::Key_R: |
1994 | mView->toggleFilter(); | 1994 | mView->toggleFilter(); |
1995 | break; | 1995 | break; |
1996 | case Qt::Key_X: | 1996 | case Qt::Key_X: |
1997 | if ( e->state() == Qt::ControlButton ) | 1997 | if ( e->state() == Qt::ControlButton ) |
1998 | mView->toggleDateNavigatorWidget(); | 1998 | mView->toggleDateNavigatorWidget(); |
1999 | else { | 1999 | else { |
2000 | mView->viewManager()->showNextXView(); | 2000 | mView->viewManager()->showNextXView(); |
2001 | showSelectedDates = true; | 2001 | showSelectedDates = true; |
2002 | } | 2002 | } |
2003 | break; | 2003 | break; |
2004 | case Qt::Key_Space: | 2004 | case Qt::Key_Space: |
2005 | mView->toggleExpand(); | 2005 | mView->toggleExpand(); |
2006 | break; | 2006 | break; |
2007 | case Qt::Key_A: | 2007 | case Qt::Key_A: |
2008 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) | 2008 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) |
2009 | mView->showNextAlarms(); | 2009 | mView->showNextAlarms(); |
2010 | else | 2010 | else |
2011 | mView->toggleAllDaySize(); | 2011 | mView->toggleAllDaySize(); |
2012 | break; | 2012 | break; |
2013 | case Qt::Key_T: | 2013 | case Qt::Key_T: |
2014 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2014 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2015 | mView->newTodo(); | 2015 | mView->newTodo(); |
2016 | else { | 2016 | else { |
2017 | mView->goToday(); | 2017 | mView->goToday(); |
2018 | showSelectedDates = true; | 2018 | showSelectedDates = true; |
2019 | } | 2019 | } |
2020 | break; | 2020 | break; |
2021 | case Qt::Key_J: | 2021 | case Qt::Key_J: |
2022 | mView->viewManager()->showJournalView(); | 2022 | mView->viewManager()->showJournalView(); |
2023 | break; | 2023 | break; |
2024 | case Qt::Key_B: | 2024 | case Qt::Key_B: |
2025 | mView->editIncidenceDescription();; | 2025 | mView->editIncidenceDescription();; |
2026 | break; | 2026 | break; |
2027 | // case Qt::Key_Return: | 2027 | // case Qt::Key_Return: |
2028 | case Qt::Key_E: | 2028 | case Qt::Key_E: |
2029 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 2029 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
2030 | mView->newEvent(); | 2030 | mView->newEvent(); |
2031 | else | 2031 | else |
2032 | mView->editIncidence(); | 2032 | mView->editIncidence(); |
2033 | break; | 2033 | break; |
2034 | case Qt::Key_Plus: | 2034 | case Qt::Key_Plus: |
2035 | size = p->mHourSize +2; | 2035 | size = p->mHourSize +2; |
2036 | if ( size <= 22 ) | 2036 | if ( size <= 22 ) |
2037 | configureAgenda( size ); | 2037 | configureAgenda( size ); |
2038 | break; | 2038 | break; |
2039 | case Qt::Key_Minus: | 2039 | case Qt::Key_Minus: |
2040 | size = p->mHourSize - 2; | 2040 | size = p->mHourSize - 2; |
2041 | if ( size >= 4 ) | 2041 | if ( size >= 4 ) |
2042 | configureAgenda( size ); | 2042 | configureAgenda( size ); |
2043 | break; | 2043 | break; |
2044 | 2044 | ||
2045 | 2045 | ||
2046 | default: | 2046 | default: |
2047 | e->ignore(); | 2047 | e->ignore(); |
2048 | } | 2048 | } |
2049 | if ( pro > 0 ) { | 2049 | if ( pro > 0 ) { |
2050 | mView->selectFilter( pro-1 ); | 2050 | mView->selectFilter( pro-1 ); |
2051 | } | 2051 | } |
2052 | if ( showSelectedDates ) { | 2052 | if ( showSelectedDates ) { |
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index f4350d9..5092d1a 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -1,306 +1,311 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <time.h> | 23 | #include <time.h> |
24 | 24 | ||
25 | #include <kdebug.h> | 25 | #include <kdebug.h> |
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #include "exceptions.h" | 29 | #include "exceptions.h" |
30 | #include "calfilter.h" | 30 | #include "calfilter.h" |
31 | 31 | ||
32 | #include "calendar.h" | 32 | #include "calendar.h" |
33 | #include "syncdefines.h" | 33 | #include "syncdefines.h" |
34 | 34 | ||
35 | using namespace KCal; | 35 | using namespace KCal; |
36 | 36 | ||
37 | Calendar::Calendar() | 37 | Calendar::Calendar() |
38 | { | 38 | { |
39 | 39 | ||
40 | init(); | 40 | init(); |
41 | setTimeZoneId( " 00:00 Europe/London(UTC)" ); | 41 | setTimeZoneId( " 00:00 Europe/London(UTC)" ); |
42 | } | 42 | } |
43 | 43 | ||
44 | Calendar::Calendar( const QString &timeZoneId ) | 44 | Calendar::Calendar( const QString &timeZoneId ) |
45 | { | 45 | { |
46 | 46 | ||
47 | init(); | 47 | init(); |
48 | setTimeZoneId(timeZoneId); | 48 | setTimeZoneId(timeZoneId); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Calendar::init() | 51 | void Calendar::init() |
52 | { | 52 | { |
53 | mObserver = 0; | 53 | mObserver = 0; |
54 | mNewObserver = false; | 54 | mNewObserver = false; |
55 | mUndoIncidence = 0; | 55 | mUndoIncidence = 0; |
56 | mDeleteIncidencesOnClose = true; | ||
56 | mModified = false; | 57 | mModified = false; |
57 | mDefaultCalendar = 1; | 58 | mDefaultCalendar = 1; |
58 | // Setup default filter, which does nothing | 59 | // Setup default filter, which does nothing |
59 | mDefaultFilter = new CalFilter; | 60 | mDefaultFilter = new CalFilter; |
60 | mFilter = mDefaultFilter; | 61 | mFilter = mDefaultFilter; |
61 | mFilter->setEnabled(false); | 62 | mFilter->setEnabled(false); |
62 | 63 | ||
63 | // initialize random numbers. This is a hack, and not | 64 | // initialize random numbers. This is a hack, and not |
64 | // even that good of one at that. | 65 | // even that good of one at that. |
65 | // srandom(time(0)); | 66 | // srandom(time(0)); |
66 | 67 | ||
67 | // user information... | 68 | // user information... |
68 | setOwner(i18n("Unknown Name")); | 69 | setOwner(i18n("Unknown Name")); |
69 | setEmail(i18n("unknown@nowhere")); | 70 | setEmail(i18n("unknown@nowhere")); |
70 | 71 | ||
71 | #if 0 | 72 | #if 0 |
72 | tmpStr = KOPrefs::instance()->mTimeZone; | 73 | tmpStr = KOPrefs::instance()->mTimeZone; |
73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; | 74 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; |
74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; | 75 | int dstSetting = KOPrefs::instance()->mDaylightSavings; |
75 | extern long int timezone; | 76 | extern long int timezone; |
76 | struct tm *now; | 77 | struct tm *now; |
77 | time_t curtime; | 78 | time_t curtime; |
78 | curtime = time(0); | 79 | curtime = time(0); |
79 | now = localtime(&curtime); | 80 | now = localtime(&curtime); |
80 | int hourOff = - ((timezone / 60) / 60); | 81 | int hourOff = - ((timezone / 60) / 60); |
81 | if (now->tm_isdst) | 82 | if (now->tm_isdst) |
82 | hourOff += 1; | 83 | hourOff += 1; |
83 | QString tzStr; | 84 | QString tzStr; |
84 | tzStr.sprintf("%.2d%.2d", | 85 | tzStr.sprintf("%.2d%.2d", |
85 | hourOff, | 86 | hourOff, |
86 | abs((timezone / 60) % 60)); | 87 | abs((timezone / 60) % 60)); |
87 | 88 | ||
88 | // if no time zone was in the config file, write what we just discovered. | 89 | // if no time zone was in the config file, write what we just discovered. |
89 | if (tmpStr.isEmpty()) { | 90 | if (tmpStr.isEmpty()) { |
90 | // KOPrefs::instance()->mTimeZone = tzStr; | 91 | // KOPrefs::instance()->mTimeZone = tzStr; |
91 | } else { | 92 | } else { |
92 | tzStr = tmpStr; | 93 | tzStr = tmpStr; |
93 | } | 94 | } |
94 | 95 | ||
95 | // if daylight savings has changed since last load time, we need | 96 | // if daylight savings has changed since last load time, we need |
96 | // to rewrite these settings to the config file. | 97 | // to rewrite these settings to the config file. |
97 | if ((now->tm_isdst && !dstSetting) || | 98 | if ((now->tm_isdst && !dstSetting) || |
98 | (!now->tm_isdst && dstSetting)) { | 99 | (!now->tm_isdst && dstSetting)) { |
99 | KOPrefs::instance()->mTimeZone = tzStr; | 100 | KOPrefs::instance()->mTimeZone = tzStr; |
100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; | 101 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; |
101 | } | 102 | } |
102 | 103 | ||
103 | setTimeZone(tzStr); | 104 | setTimeZone(tzStr); |
104 | #endif | 105 | #endif |
105 | 106 | ||
106 | // KOPrefs::instance()->writeConfig(); | 107 | // KOPrefs::instance()->writeConfig(); |
107 | } | 108 | } |
108 | 109 | ||
109 | Calendar::~Calendar() | 110 | Calendar::~Calendar() |
110 | { | 111 | { |
111 | delete mDefaultFilter; | 112 | delete mDefaultFilter; |
112 | if ( mUndoIncidence ) | 113 | if ( mUndoIncidence ) |
113 | delete mUndoIncidence; | 114 | delete mUndoIncidence; |
114 | } | 115 | } |
116 | void Calendar::setDontDeleteIncidencesOnClose () | ||
117 | { | ||
118 | mDeleteIncidencesOnClose = false; | ||
119 | } | ||
115 | void Calendar::setDefaultCalendar( int d ) | 120 | void Calendar::setDefaultCalendar( int d ) |
116 | { | 121 | { |
117 | mDefaultCalendar = d; | 122 | mDefaultCalendar = d; |
118 | } | 123 | } |
119 | int Calendar::defaultCalendar() | 124 | int Calendar::defaultCalendar() |
120 | { | 125 | { |
121 | return mDefaultCalendar; | 126 | return mDefaultCalendar; |
122 | } | 127 | } |
123 | const QString &Calendar::getOwner() const | 128 | const QString &Calendar::getOwner() const |
124 | { | 129 | { |
125 | return mOwner; | 130 | return mOwner; |
126 | } | 131 | } |
127 | 132 | ||
128 | bool Calendar::undoDeleteIncidence() | 133 | bool Calendar::undoDeleteIncidence() |
129 | { | 134 | { |
130 | if (!mUndoIncidence) | 135 | if (!mUndoIncidence) |
131 | return false; | 136 | return false; |
132 | addIncidence(mUndoIncidence); | 137 | addIncidence(mUndoIncidence); |
133 | mUndoIncidence = 0; | 138 | mUndoIncidence = 0; |
134 | return true; | 139 | return true; |
135 | } | 140 | } |
136 | void Calendar::setOwner(const QString &os) | 141 | void Calendar::setOwner(const QString &os) |
137 | { | 142 | { |
138 | int i; | 143 | int i; |
139 | mOwner = os; | 144 | mOwner = os; |
140 | i = mOwner.find(','); | 145 | i = mOwner.find(','); |
141 | if (i != -1) | 146 | if (i != -1) |
142 | mOwner = mOwner.left(i); | 147 | mOwner = mOwner.left(i); |
143 | 148 | ||
144 | setModified( true ); | 149 | setModified( true ); |
145 | } | 150 | } |
146 | 151 | ||
147 | void Calendar::setTimeZone(const QString & tz) | 152 | void Calendar::setTimeZone(const QString & tz) |
148 | { | 153 | { |
149 | bool neg = FALSE; | 154 | bool neg = FALSE; |
150 | int hours, minutes; | 155 | int hours, minutes; |
151 | QString tmpStr(tz); | 156 | QString tmpStr(tz); |
152 | 157 | ||
153 | if (tmpStr.left(1) == "-") | 158 | if (tmpStr.left(1) == "-") |
154 | neg = TRUE; | 159 | neg = TRUE; |
155 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") | 160 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") |
156 | tmpStr.remove(0, 1); | 161 | tmpStr.remove(0, 1); |
157 | hours = tmpStr.left(2).toInt(); | 162 | hours = tmpStr.left(2).toInt(); |
158 | if (tmpStr.length() > 2) | 163 | if (tmpStr.length() > 2) |
159 | minutes = tmpStr.right(2).toInt(); | 164 | minutes = tmpStr.right(2).toInt(); |
160 | else | 165 | else |
161 | minutes = 0; | 166 | minutes = 0; |
162 | mTimeZone = (60*hours+minutes); | 167 | mTimeZone = (60*hours+minutes); |
163 | if (neg) | 168 | if (neg) |
164 | mTimeZone = -mTimeZone; | 169 | mTimeZone = -mTimeZone; |
165 | mLocalTime = false; | 170 | mLocalTime = false; |
166 | 171 | ||
167 | setModified( true ); | 172 | setModified( true ); |
168 | } | 173 | } |
169 | 174 | ||
170 | QString Calendar::getTimeZoneStr() const | 175 | QString Calendar::getTimeZoneStr() const |
171 | { | 176 | { |
172 | if (mLocalTime) | 177 | if (mLocalTime) |
173 | return ""; | 178 | return ""; |
174 | QString tmpStr; | 179 | QString tmpStr; |
175 | int hours = abs(mTimeZone / 60); | 180 | int hours = abs(mTimeZone / 60); |
176 | int minutes = abs(mTimeZone % 60); | 181 | int minutes = abs(mTimeZone % 60); |
177 | bool neg = mTimeZone < 0; | 182 | bool neg = mTimeZone < 0; |
178 | 183 | ||
179 | tmpStr.sprintf("%c%.2d%.2d", | 184 | tmpStr.sprintf("%c%.2d%.2d", |
180 | (neg ? '-' : '+'), | 185 | (neg ? '-' : '+'), |
181 | hours, minutes); | 186 | hours, minutes); |
182 | return tmpStr; | 187 | return tmpStr; |
183 | } | 188 | } |
184 | 189 | ||
185 | void Calendar::setTimeZone(int tz) | 190 | void Calendar::setTimeZone(int tz) |
186 | { | 191 | { |
187 | mTimeZone = tz; | 192 | mTimeZone = tz; |
188 | mLocalTime = false; | 193 | mLocalTime = false; |
189 | 194 | ||
190 | setModified( true ); | 195 | setModified( true ); |
191 | } | 196 | } |
192 | 197 | ||
193 | int Calendar::getTimeZone() const | 198 | int Calendar::getTimeZone() const |
194 | { | 199 | { |
195 | return mTimeZone; | 200 | return mTimeZone; |
196 | } | 201 | } |
197 | 202 | ||
198 | void Calendar::setTimeZoneId(const QString &id) | 203 | void Calendar::setTimeZoneId(const QString &id) |
199 | { | 204 | { |
200 | mTimeZoneId = id; | 205 | mTimeZoneId = id; |
201 | mLocalTime = false; | 206 | mLocalTime = false; |
202 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); | 207 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); |
203 | if ( mTimeZone > 1000) | 208 | if ( mTimeZone > 1000) |
204 | setLocalTime(); | 209 | setLocalTime(); |
205 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); | 210 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); |
206 | setModified( true ); | 211 | setModified( true ); |
207 | } | 212 | } |
208 | 213 | ||
209 | QString Calendar::timeZoneId() const | 214 | QString Calendar::timeZoneId() const |
210 | { | 215 | { |
211 | return mTimeZoneId; | 216 | return mTimeZoneId; |
212 | } | 217 | } |
213 | 218 | ||
214 | void Calendar::setLocalTime() | 219 | void Calendar::setLocalTime() |
215 | { | 220 | { |
216 | //qDebug("Calendar::setLocalTime() "); | 221 | //qDebug("Calendar::setLocalTime() "); |
217 | mLocalTime = true; | 222 | mLocalTime = true; |
218 | mTimeZone = 0; | 223 | mTimeZone = 0; |
219 | mTimeZoneId = ""; | 224 | mTimeZoneId = ""; |
220 | 225 | ||
221 | setModified( true ); | 226 | setModified( true ); |
222 | } | 227 | } |
223 | 228 | ||
224 | bool Calendar::isLocalTime() const | 229 | bool Calendar::isLocalTime() const |
225 | { | 230 | { |
226 | return mLocalTime; | 231 | return mLocalTime; |
227 | } | 232 | } |
228 | 233 | ||
229 | const QString &Calendar::getEmail() | 234 | const QString &Calendar::getEmail() |
230 | { | 235 | { |
231 | return mOwnerEmail; | 236 | return mOwnerEmail; |
232 | } | 237 | } |
233 | 238 | ||
234 | void Calendar::setEmail(const QString &e) | 239 | void Calendar::setEmail(const QString &e) |
235 | { | 240 | { |
236 | mOwnerEmail = e; | 241 | mOwnerEmail = e; |
237 | 242 | ||
238 | setModified( true ); | 243 | setModified( true ); |
239 | } | 244 | } |
240 | 245 | ||
241 | void Calendar::setFilter(CalFilter *filter) | 246 | void Calendar::setFilter(CalFilter *filter) |
242 | { | 247 | { |
243 | mFilter = filter; | 248 | mFilter = filter; |
244 | } | 249 | } |
245 | 250 | ||
246 | CalFilter *Calendar::filter() | 251 | CalFilter *Calendar::filter() |
247 | { | 252 | { |
248 | return mFilter; | 253 | return mFilter; |
249 | } | 254 | } |
250 | 255 | ||
251 | QPtrList<Incidence> Calendar::incidences() | 256 | QPtrList<Incidence> Calendar::incidences() |
252 | { | 257 | { |
253 | QPtrList<Incidence> incidences; | 258 | QPtrList<Incidence> incidences; |
254 | 259 | ||
255 | Incidence *i; | 260 | Incidence *i; |
256 | 261 | ||
257 | QPtrList<Event> e = events(); | 262 | QPtrList<Event> e = events(); |
258 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 263 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
259 | 264 | ||
260 | QPtrList<Todo> t = todos(); | 265 | QPtrList<Todo> t = todos(); |
261 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 266 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
262 | 267 | ||
263 | QPtrList<Journal> j = journals(); | 268 | QPtrList<Journal> j = journals(); |
264 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 269 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
265 | 270 | ||
266 | return incidences; | 271 | return incidences; |
267 | } | 272 | } |
268 | 273 | ||
269 | void Calendar::resetPilotStat(int id ) | 274 | void Calendar::resetPilotStat(int id ) |
270 | { | 275 | { |
271 | QPtrList<Incidence> incidences; | 276 | QPtrList<Incidence> incidences; |
272 | 277 | ||
273 | Incidence *i; | 278 | Incidence *i; |
274 | 279 | ||
275 | QPtrList<Event> e = rawEvents(); | 280 | QPtrList<Event> e = rawEvents(); |
276 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); | 281 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); |
277 | 282 | ||
278 | QPtrList<Todo> t = rawTodos(); | 283 | QPtrList<Todo> t = rawTodos(); |
279 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); | 284 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); |
280 | 285 | ||
281 | QPtrList<Journal> j = journals(); | 286 | QPtrList<Journal> j = journals(); |
282 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); | 287 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); |
283 | } | 288 | } |
284 | void Calendar::resetTempSyncStat() | 289 | void Calendar::resetTempSyncStat() |
285 | { | 290 | { |
286 | QPtrList<Incidence> incidences; | 291 | QPtrList<Incidence> incidences; |
287 | 292 | ||
288 | Incidence *i; | 293 | Incidence *i; |
289 | 294 | ||
290 | QPtrList<Event> e = rawEvents(); | 295 | QPtrList<Event> e = rawEvents(); |
291 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 296 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
292 | 297 | ||
293 | QPtrList<Todo> t = rawTodos(); | 298 | QPtrList<Todo> t = rawTodos(); |
294 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 299 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
295 | 300 | ||
296 | QPtrList<Journal> j = journals(); | 301 | QPtrList<Journal> j = journals(); |
297 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 302 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
298 | } | 303 | } |
299 | QPtrList<Incidence> Calendar::rawIncidences() | 304 | QPtrList<Incidence> Calendar::rawIncidences() |
300 | { | 305 | { |
301 | QPtrList<Incidence> incidences; | 306 | QPtrList<Incidence> incidences; |
302 | 307 | ||
303 | Incidence *i; | 308 | Incidence *i; |
304 | 309 | ||
305 | QPtrList<Event> e = rawEvents(); | 310 | QPtrList<Event> e = rawEvents(); |
306 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 311 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 4c6760f..73f82bb 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,366 +1,373 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef CALENDAR_H | 22 | #ifndef CALENDAR_H |
23 | #define CALENDAR_H | 23 | #define CALENDAR_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "event.h" | 32 | #include "event.h" |
33 | #include "todo.h" | 33 | #include "todo.h" |
34 | #include "journal.h" | 34 | #include "journal.h" |
35 | #include "calfilter.h" | 35 | #include "calfilter.h" |
36 | 36 | ||
37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ | 37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ |
38 | 38 | ||
39 | class KConfig; | 39 | class KConfig; |
40 | 40 | ||
41 | namespace KCal { | 41 | namespace KCal { |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | This is the main "calendar" object class for KOrganizer. It holds | 45 | This is the main "calendar" object class for KOrganizer. It holds |
46 | information like all appointments/events, user information, etc. etc. | 46 | information like all appointments/events, user information, etc. etc. |
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
53 | event (or any other subclass of IncidenceBase) object is added to the | 53 | event (or any other subclass of IncidenceBase) object is added to the |
54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes | 54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes |
55 | care of deleting it. All Events returned by the query functions are returned | 55 | care of deleting it. All Events returned by the query functions are returned |
56 | as pointers, that means all changes to the returned events are immediately | 56 | as pointers, that means all changes to the returned events are immediately |
57 | visible in the Calendar. You shouldn't delete any Event object you get from | 57 | visible in the Calendar. You shouldn't delete any Event object you get from |
58 | Calendar. | 58 | Calendar. |
59 | */ | 59 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | Incidence * undoIncidence() { return mUndoIncidence; }; | 68 | Incidence * undoIncidence() { return mUndoIncidence; }; |
69 | bool undoDeleteIncidence(); | 69 | bool undoDeleteIncidence(); |
70 | void deleteIncidence(Incidence *in); | 70 | void deleteIncidence(Incidence *in); |
71 | void resetTempSyncStat(); | 71 | void resetTempSyncStat(); |
72 | void resetPilotStat(int id); | 72 | void resetPilotStat(int id); |
73 | /** | 73 | /** |
74 | Clears out the current calendar, freeing all used memory etc. | 74 | Clears out the current calendar, freeing all used memory etc. |
75 | */ | 75 | */ |
76 | virtual void close() = 0; | 76 | virtual void close() = 0; |
77 | virtual void addCalendar( Calendar* ) = 0; | ||
78 | virtual bool addCalendarFile( QString name, int id ) = 0; | ||
77 | 79 | ||
78 | /** | 80 | /** |
79 | Sync changes in memory to persistant storage. | 81 | Sync changes in memory to persistant storage. |
80 | */ | 82 | */ |
81 | virtual void save() = 0; | 83 | virtual void save() = 0; |
82 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 84 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
83 | virtual void removeSyncInfo( QString syncProfile) = 0; | 85 | virtual void removeSyncInfo( QString syncProfile) = 0; |
84 | virtual bool isSaving() { return false; } | 86 | virtual bool isSaving() { return false; } |
85 | 87 | ||
86 | /** | 88 | /** |
87 | Return the owner of the calendar's full name. | 89 | Return the owner of the calendar's full name. |
88 | */ | 90 | */ |
89 | const QString &getOwner() const; | 91 | const QString &getOwner() const; |
90 | /** | 92 | /** |
91 | Set the owner of the calendar. Should be owner's full name. | 93 | Set the owner of the calendar. Should be owner's full name. |
92 | */ | 94 | */ |
93 | void setOwner( const QString &os ); | 95 | void setOwner( const QString &os ); |
94 | /** | 96 | /** |
95 | Return the email address of the calendar owner. | 97 | Return the email address of the calendar owner. |
96 | */ | 98 | */ |
97 | const QString &getEmail(); | 99 | const QString &getEmail(); |
98 | /** | 100 | /** |
99 | Set the email address of the calendar owner. | 101 | Set the email address of the calendar owner. |
100 | */ | 102 | */ |
101 | void setEmail( const QString & ); | 103 | void setEmail( const QString & ); |
102 | 104 | ||
103 | /** | 105 | /** |
104 | Set time zone from a timezone string (e.g. -2:00) | 106 | Set time zone from a timezone string (e.g. -2:00) |
105 | */ | 107 | */ |
106 | void setTimeZone( const QString &tz ); | 108 | void setTimeZone( const QString &tz ); |
107 | /** | 109 | /** |
108 | Set time zone from a minutes value (e.g. -60) | 110 | Set time zone from a minutes value (e.g. -60) |
109 | */ | 111 | */ |
110 | void setTimeZone( int tz ); | 112 | void setTimeZone( int tz ); |
111 | /** | 113 | /** |
112 | Return time zone as offest in minutes. | 114 | Return time zone as offest in minutes. |
113 | */ | 115 | */ |
114 | int getTimeZone() const; | 116 | int getTimeZone() const; |
115 | /** | 117 | /** |
116 | Compute an ISO 8601 format string from the time zone. | 118 | Compute an ISO 8601 format string from the time zone. |
117 | */ | 119 | */ |
118 | QString getTimeZoneStr() const; | 120 | QString getTimeZoneStr() const; |
119 | /** | 121 | /** |
120 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 122 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
121 | values). | 123 | values). |
122 | */ | 124 | */ |
123 | void setTimeZoneId( const QString & ); | 125 | void setTimeZoneId( const QString & ); |
124 | /** | 126 | /** |
125 | Return time zone id. | 127 | Return time zone id. |
126 | */ | 128 | */ |
127 | QString timeZoneId() const; | 129 | QString timeZoneId() const; |
128 | /** | 130 | /** |
129 | Use local time, not UTC or a time zone. | 131 | Use local time, not UTC or a time zone. |
130 | */ | 132 | */ |
131 | void setLocalTime(); | 133 | void setLocalTime(); |
132 | /** | 134 | /** |
133 | Return whether local time is being used. | 135 | Return whether local time is being used. |
134 | */ | 136 | */ |
135 | bool isLocalTime() const; | 137 | bool isLocalTime() const; |
136 | 138 | ||
137 | /** | 139 | /** |
138 | Add an incidence to calendar. | 140 | Add an incidence to calendar. |
139 | 141 | ||
140 | @return true on success, false on error. | 142 | @return true on success, false on error. |
141 | */ | 143 | */ |
142 | virtual bool addIncidence( Incidence * ); | 144 | virtual bool addIncidence( Incidence * ); |
143 | 145 | ||
144 | // Adds an incidence and all relatedto incidences to the cal | 146 | // Adds an incidence and all relatedto incidences to the cal |
145 | void addIncidenceBranch( Incidence * ); | 147 | void addIncidenceBranch( Incidence * ); |
146 | /** | 148 | /** |
147 | Return filtered list of all incidences of this calendar. | 149 | Return filtered list of all incidences of this calendar. |
148 | */ | 150 | */ |
149 | virtual QPtrList<Incidence> incidences(); | 151 | virtual QPtrList<Incidence> incidences(); |
150 | 152 | ||
151 | /** | 153 | /** |
152 | Return unfiltered list of all incidences of this calendar. | 154 | Return unfiltered list of all incidences of this calendar. |
153 | */ | 155 | */ |
154 | virtual QPtrList<Incidence> rawIncidences(); | 156 | virtual QPtrList<Incidence> rawIncidences(); |
155 | 157 | ||
156 | /** | 158 | /** |
157 | Adds a Event to this calendar object. | 159 | Adds a Event to this calendar object. |
158 | @param anEvent a pointer to the event to add | 160 | @param anEvent a pointer to the event to add |
159 | 161 | ||
160 | @return true on success, false on error. | 162 | @return true on success, false on error. |
161 | */ | 163 | */ |
162 | virtual bool addEventNoDup( Event *event ) = 0; | 164 | virtual bool addEventNoDup( Event *event ) = 0; |
163 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 165 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
164 | virtual bool addEvent( Event *anEvent ) = 0; | 166 | virtual bool addEvent( Event *anEvent ) = 0; |
165 | /** | 167 | /** |
166 | Delete event from calendar. | 168 | Delete event from calendar. |
167 | */ | 169 | */ |
168 | virtual void deleteEvent( Event * ) = 0; | 170 | virtual void deleteEvent( Event * ) = 0; |
169 | /** | 171 | /** |
170 | Retrieves an event on the basis of the unique string ID. | 172 | Retrieves an event on the basis of the unique string ID. |
171 | */ | 173 | */ |
172 | virtual Event *event( const QString &UniqueStr ) = 0; | 174 | virtual Event *event( const QString &UniqueStr ) = 0; |
173 | virtual Event *event( QString, QString ) = 0; | 175 | virtual Event *event( QString, QString ) = 0; |
174 | /** | 176 | /** |
175 | Builds and then returns a list of all events that match for the | 177 | Builds and then returns a list of all events that match for the |
176 | date specified. useful for dayView, etc. etc. | 178 | date specified. useful for dayView, etc. etc. |
177 | The calendar filter is applied. | 179 | The calendar filter is applied. |
178 | */ | 180 | */ |
179 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 181 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
180 | /** | 182 | /** |
181 | Get events, which occur on the given date. | 183 | Get events, which occur on the given date. |
182 | The calendar filter is applied. | 184 | The calendar filter is applied. |
183 | */ | 185 | */ |
184 | QPtrList<Event> events( const QDateTime &qdt ); | 186 | QPtrList<Event> events( const QDateTime &qdt ); |
185 | /** | 187 | /** |
186 | Get events in a range of dates. If inclusive is set to true, only events | 188 | Get events in a range of dates. If inclusive is set to true, only events |
187 | are returned, which are completely included in the range. | 189 | are returned, which are completely included in the range. |
188 | The calendar filter is applied. | 190 | The calendar filter is applied. |
189 | */ | 191 | */ |
190 | QPtrList<Event> events( const QDate &start, const QDate &end, | 192 | QPtrList<Event> events( const QDate &start, const QDate &end, |
191 | bool inclusive = false); | 193 | bool inclusive = false); |
192 | /** | 194 | /** |
193 | Return filtered list of all events in calendar. | 195 | Return filtered list of all events in calendar. |
194 | */ | 196 | */ |
195 | virtual QPtrList<Event> events(); | 197 | virtual QPtrList<Event> events(); |
196 | /** | 198 | /** |
197 | Return unfiltered list of all events in calendar. | 199 | Return unfiltered list of all events in calendar. |
198 | */ | 200 | */ |
199 | virtual QPtrList<Event> rawEvents() = 0; | 201 | virtual QPtrList<Event> rawEvents() = 0; |
200 | 202 | ||
201 | /** | 203 | /** |
202 | Add a todo to the todolist. | 204 | Add a todo to the todolist. |
203 | 205 | ||
204 | @return true on success, false on error. | 206 | @return true on success, false on error. |
205 | */ | 207 | */ |
206 | virtual bool addTodo( Todo *todo ) = 0; | 208 | virtual bool addTodo( Todo *todo ) = 0; |
207 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 209 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
208 | /** | 210 | /** |
209 | Remove a todo from the todolist. | 211 | Remove a todo from the todolist. |
210 | */ | 212 | */ |
211 | virtual void deleteTodo( Todo * ) = 0; | 213 | virtual void deleteTodo( Todo * ) = 0; |
212 | virtual void deleteJournal( Journal * ) = 0; | 214 | virtual void deleteJournal( Journal * ) = 0; |
213 | /** | 215 | /** |
214 | Return filterd list of todos. | 216 | Return filterd list of todos. |
215 | */ | 217 | */ |
216 | virtual QPtrList<Todo> todos(); | 218 | virtual QPtrList<Todo> todos(); |
217 | /** | 219 | /** |
218 | Searches todolist for an event with this unique string identifier, | 220 | Searches todolist for an event with this unique string identifier, |
219 | returns a pointer or null. | 221 | returns a pointer or null. |
220 | */ | 222 | */ |
221 | virtual Todo *todo( const QString &uid ) = 0; | 223 | virtual Todo *todo( const QString &uid ) = 0; |
222 | virtual Todo *todo( QString, QString ) = 0; | 224 | virtual Todo *todo( QString, QString ) = 0; |
223 | /** | 225 | /** |
224 | Returns list of todos due on the specified date. | 226 | Returns list of todos due on the specified date. |
225 | */ | 227 | */ |
226 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 228 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
227 | /** | 229 | /** |
228 | Return unfiltered list of todos. | 230 | Return unfiltered list of todos. |
229 | */ | 231 | */ |
230 | virtual QPtrList<Todo> rawTodos() = 0; | 232 | virtual QPtrList<Todo> rawTodos() = 0; |
231 | 233 | ||
232 | /** | 234 | /** |
233 | Add a Journal entry to calendar. | 235 | Add a Journal entry to calendar. |
234 | 236 | ||
235 | @return true on success, false on error. | 237 | @return true on success, false on error. |
236 | */ | 238 | */ |
237 | virtual bool addJournal( Journal * ) = 0; | 239 | virtual bool addJournal( Journal * ) = 0; |
238 | /** | 240 | /** |
239 | Return Journal for given date. | 241 | Return Journal for given date. |
240 | */ | 242 | */ |
241 | virtual Journal *journal( const QDate & ) = 0; | 243 | virtual Journal *journal( const QDate & ) = 0; |
242 | /** | 244 | /** |
243 | Return Journal with given UID. | 245 | Return Journal with given UID. |
244 | */ | 246 | */ |
245 | virtual Journal *journal( const QString &UID ) = 0; | 247 | virtual Journal *journal( const QString &UID ) = 0; |
246 | /** | 248 | /** |
247 | Return list of all Journal entries. | 249 | Return list of all Journal entries. |
248 | */ | 250 | */ |
249 | virtual QPtrList<Journal> journals() = 0; | 251 | virtual QPtrList<Journal> journals() = 0; |
250 | 252 | ||
251 | /** | 253 | /** |
252 | Searches all incidence types for an incidence with this unique | 254 | Searches all incidence types for an incidence with this unique |
253 | string identifier, returns a pointer or null. | 255 | string identifier, returns a pointer or null. |
254 | */ | 256 | */ |
255 | Incidence* incidence( const QString&UID ); | 257 | Incidence* incidence( const QString&UID ); |
256 | 258 | ||
257 | /** | 259 | /** |
258 | Setup relations for an incidence. | 260 | Setup relations for an incidence. |
259 | */ | 261 | */ |
260 | virtual void setupRelations( Incidence * ); | 262 | virtual void setupRelations( Incidence * ); |
261 | /** | 263 | /** |
262 | Remove all relations to an incidence | 264 | Remove all relations to an incidence |
263 | */ | 265 | */ |
264 | virtual void removeRelations( Incidence * ); | 266 | virtual void removeRelations( Incidence * ); |
265 | 267 | ||
266 | /** | 268 | /** |
267 | Set calendar filter, which filters events for the events() functions. | 269 | Set calendar filter, which filters events for the events() functions. |
268 | The Filter object is owned by the caller. | 270 | The Filter object is owned by the caller. |
269 | */ | 271 | */ |
270 | void setFilter( CalFilter * ); | 272 | void setFilter( CalFilter * ); |
271 | /** | 273 | /** |
272 | Return calendar filter. | 274 | Return calendar filter. |
273 | */ | 275 | */ |
274 | CalFilter *filter(); | 276 | CalFilter *filter(); |
275 | virtual QDateTime nextAlarm( int daysTo ) = 0; | 277 | virtual QDateTime nextAlarm( int daysTo ) = 0; |
276 | virtual QString nextSummary( ) const = 0; | 278 | virtual QString nextSummary( ) const = 0; |
277 | virtual void reInitAlarmSettings() = 0; | 279 | virtual void reInitAlarmSettings() = 0; |
278 | virtual QDateTime nextAlarmEventDateTime() const = 0; | 280 | virtual QDateTime nextAlarmEventDateTime() const = 0; |
279 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; | 281 | virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; |
280 | /** | 282 | /** |
281 | Return all alarms, which ocur in the given time interval. | 283 | Return all alarms, which ocur in the given time interval. |
282 | */ | 284 | */ |
283 | virtual Alarm::List alarms( const QDateTime &from, | 285 | virtual Alarm::List alarms( const QDateTime &from, |
284 | const QDateTime &to ) = 0; | 286 | const QDateTime &to ) = 0; |
285 | 287 | ||
286 | class Observer { | 288 | class Observer { |
287 | public: | 289 | public: |
288 | virtual void calendarModified( bool, Calendar * ) = 0; | 290 | virtual void calendarModified( bool, Calendar * ) = 0; |
289 | }; | 291 | }; |
290 | 292 | ||
291 | void registerObserver( Observer * ); | 293 | void registerObserver( Observer * ); |
292 | 294 | ||
293 | void setModified( bool ); | 295 | void setModified( bool ); |
294 | 296 | ||
295 | /** | 297 | /** |
296 | Set product id returned by loadedProductId(). This function is only | 298 | Set product id returned by loadedProductId(). This function is only |
297 | useful for the calendar loading code. | 299 | useful for the calendar loading code. |
298 | */ | 300 | */ |
299 | void setLoadedProductId( const QString & ); | 301 | void setLoadedProductId( const QString & ); |
300 | /** | 302 | /** |
301 | Return product id taken from file that has been loaded. Returns | 303 | Return product id taken from file that has been loaded. Returns |
302 | QString::null, if no calendar has been loaded. | 304 | QString::null, if no calendar has been loaded. |
303 | */ | 305 | */ |
304 | QString loadedProductId(); | 306 | QString loadedProductId(); |
305 | void setDefaultCalendar( int ); | ||
306 | int defaultCalendar(); | 307 | int defaultCalendar(); |
308 | void setDontDeleteIncidencesOnClose (); | ||
309 | public slots: | ||
310 | void setDefaultCalendar( int ); | ||
307 | virtual void setCalendarEnabled( int id, bool enable ) = 0; | 311 | virtual void setCalendarEnabled( int id, bool enable ) = 0; |
308 | virtual void setAlarmEnabled( int id, bool enable ) = 0; | 312 | virtual void setAlarmEnabled( int id, bool enable ) = 0; |
313 | virtual void setReadOnly( int id, bool enable ) = 0; | ||
309 | virtual void setDefaultCalendarEnabledOnly() = 0; | 314 | virtual void setDefaultCalendarEnabledOnly() = 0; |
310 | signals: | 315 | signals: |
311 | void calendarChanged(); | 316 | void calendarChanged(); |
312 | void calendarSaved(); | 317 | void calendarSaved(); |
313 | void calendarLoaded(); | 318 | void calendarLoaded(); |
314 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 319 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
315 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 320 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
316 | 321 | ||
317 | protected: | 322 | protected: |
318 | /** | 323 | /** |
319 | Get unfiltered events, which occur on the given date. | 324 | Get unfiltered events, which occur on the given date. |
320 | */ | 325 | */ |
321 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; | 326 | virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; |
322 | /** | 327 | /** |
323 | Get unfiltered events, which occur on the given date. | 328 | Get unfiltered events, which occur on the given date. |
324 | */ | 329 | */ |
325 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, | 330 | virtual QPtrList<Event> rawEventsForDate( const QDate &date, |
326 | bool sorted = false ) = 0; | 331 | bool sorted = false ) = 0; |
327 | /** | 332 | /** |
328 | Get events in a range of dates. If inclusive is set to true, only events | 333 | Get events in a range of dates. If inclusive is set to true, only events |
329 | are returned, which are completely included in the range. | 334 | are returned, which are completely included in the range. |
330 | */ | 335 | */ |
331 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 336 | virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
332 | bool inclusive = false ) = 0; | 337 | bool inclusive = false ) = 0; |
333 | 338 | ||
334 | Incidence *mNextAlarmIncidence; | 339 | Incidence *mNextAlarmIncidence; |
335 | Incidence *mUndoIncidence; | 340 | Incidence *mUndoIncidence; |
336 | int mDefaultCalendar; | 341 | int mDefaultCalendar; |
342 | bool mDeleteIncidencesOnClose; | ||
337 | 343 | ||
338 | private: | 344 | private: |
339 | void init(); | 345 | void init(); |
340 | 346 | ||
341 | QString mOwner; // who the calendar belongs to | 347 | QString mOwner; // who the calendar belongs to |
342 | QString mOwnerEmail; // email address of the owner | 348 | QString mOwnerEmail; // email address of the owner |
343 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) | 349 | int mTimeZone; // timezone OFFSET from GMT (MINUTES) |
344 | bool mLocalTime; // use local time, not UTC or a time zone | 350 | bool mLocalTime; // use local time, not UTC or a time zone |
345 | 351 | ||
352 | |||
346 | CalFilter *mFilter; | 353 | CalFilter *mFilter; |
347 | CalFilter *mDefaultFilter; | 354 | CalFilter *mDefaultFilter; |
348 | 355 | ||
349 | 356 | ||
350 | QString mTimeZoneId; | 357 | QString mTimeZoneId; |
351 | 358 | ||
352 | Observer *mObserver; | 359 | Observer *mObserver; |
353 | bool mNewObserver; | 360 | bool mNewObserver; |
354 | 361 | ||
355 | bool mModified; | 362 | bool mModified; |
356 | 363 | ||
357 | QString mLoadedProductId; | 364 | QString mLoadedProductId; |
358 | 365 | ||
359 | // This list is used to put together related todos | 366 | // This list is used to put together related todos |
360 | QDict<Incidence> mOrphans; | 367 | QDict<Incidence> mOrphans; |
361 | QDict<Incidence> mOrphanUids; | 368 | QDict<Incidence> mOrphanUids; |
362 | }; | 369 | }; |
363 | 370 | ||
364 | } | 371 | } |
365 | 372 | ||
366 | #endif | 373 | #endif |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index c5500bf..e48122a 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -1,262 +1,300 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | 31 | ||
32 | #include "vcaldrag.h" | 32 | #include "vcaldrag.h" |
33 | #include "vcalformat.h" | 33 | #include "vcalformat.h" |
34 | #include "icalformat.h" | 34 | #include "icalformat.h" |
35 | #include "exceptions.h" | 35 | #include "exceptions.h" |
36 | #include "incidence.h" | 36 | #include "incidence.h" |
37 | #include "journal.h" | 37 | #include "journal.h" |
38 | #include "filestorage.h" | 38 | #include "filestorage.h" |
39 | #include "calfilter.h" | 39 | #include "calfilter.h" |
40 | 40 | ||
41 | #include "calendarlocal.h" | 41 | #include "calendarlocal.h" |
42 | 42 | ||
43 | // #ifndef DESKTOP_VERSION | 43 | // #ifndef DESKTOP_VERSION |
44 | // #include <qtopia/alarmserver.h> | 44 | // #include <qtopia/alarmserver.h> |
45 | // #endif | 45 | // #endif |
46 | using namespace KCal; | 46 | using namespace KCal; |
47 | 47 | ||
48 | CalendarLocal::CalendarLocal() | 48 | CalendarLocal::CalendarLocal() |
49 | : Calendar() | 49 | : Calendar() |
50 | { | 50 | { |
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) | 54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) |
55 | : Calendar(timeZoneId) | 55 | : Calendar(timeZoneId) |
56 | { | 56 | { |
57 | init(); | 57 | init(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void CalendarLocal::init() | 60 | void CalendarLocal::init() |
61 | { | 61 | { |
62 | mNextAlarmIncidence = 0; | 62 | mNextAlarmIncidence = 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | CalendarLocal::~CalendarLocal() | 66 | CalendarLocal::~CalendarLocal() |
67 | { | 67 | { |
68 | close(); | 68 | if ( mDeleteIncidencesOnClose ) |
69 | close(); | ||
70 | } | ||
71 | bool CalendarLocal::addCalendarFile( QString name, int id ) | ||
72 | { | ||
73 | CalendarLocal calendar( timeZoneId() ); | ||
74 | calendar.setDefaultCalendar( id ); | ||
75 | if ( calendar.load( name ) ) { | ||
76 | addCalendar( &calendar ); | ||
77 | return true; | ||
78 | } | ||
79 | return false; | ||
80 | } | ||
81 | void CalendarLocal::addCalendar( Calendar* cal ) | ||
82 | { | ||
83 | cal->setDontDeleteIncidencesOnClose(); | ||
84 | { | ||
85 | QPtrList<Event> EventList = cal->rawEvents(); | ||
86 | Event * ev = EventList.first(); | ||
87 | while ( ev ) { | ||
88 | mEventList.append( ev ); | ||
89 | ev = EventList.next(); | ||
90 | } | ||
91 | } | ||
92 | { | ||
93 | QPtrList<Todo> TodoList = cal->rawTodos(); | ||
94 | Todo * ev = TodoList.first(); | ||
95 | while ( ev ) { | ||
96 | mTodoList.append( ev ); | ||
97 | ev = TodoList.next(); | ||
98 | } | ||
99 | } | ||
100 | { | ||
101 | QPtrList<Journal> JournalList = cal->journals(); | ||
102 | Journal * ev = JournalList.first(); | ||
103 | while ( ev ) { | ||
104 | mJournalList.append( ev ); | ||
105 | ev = JournalList.next(); | ||
106 | } | ||
107 | } | ||
69 | } | 108 | } |
70 | |||
71 | bool CalendarLocal::load( const QString &fileName ) | 109 | bool CalendarLocal::load( const QString &fileName ) |
72 | { | 110 | { |
73 | FileStorage storage( this, fileName ); | 111 | FileStorage storage( this, fileName ); |
74 | return storage.load(); | 112 | return storage.load(); |
75 | } | 113 | } |
76 | 114 | ||
77 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 115 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
78 | { | 116 | { |
79 | FileStorage storage( this, fileName, format ); | 117 | FileStorage storage( this, fileName, format ); |
80 | return storage.save(); | 118 | return storage.save(); |
81 | } | 119 | } |
82 | 120 | ||
83 | void CalendarLocal::close() | 121 | void CalendarLocal::close() |
84 | { | 122 | { |
85 | 123 | ||
86 | Todo * i; | 124 | Todo * i; |
87 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); | 125 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); |
88 | 126 | ||
89 | mEventList.setAutoDelete( true ); | 127 | mEventList.setAutoDelete( true ); |
90 | mTodoList.setAutoDelete( true ); | 128 | mTodoList.setAutoDelete( true ); |
91 | mJournalList.setAutoDelete( false ); | 129 | mJournalList.setAutoDelete( false ); |
92 | 130 | ||
93 | mEventList.clear(); | 131 | mEventList.clear(); |
94 | mTodoList.clear(); | 132 | mTodoList.clear(); |
95 | mJournalList.clear(); | 133 | mJournalList.clear(); |
96 | 134 | ||
97 | mEventList.setAutoDelete( false ); | 135 | mEventList.setAutoDelete( false ); |
98 | mTodoList.setAutoDelete( false ); | 136 | mTodoList.setAutoDelete( false ); |
99 | mJournalList.setAutoDelete( false ); | 137 | mJournalList.setAutoDelete( false ); |
100 | 138 | ||
101 | setModified( false ); | 139 | setModified( false ); |
102 | } | 140 | } |
103 | 141 | ||
104 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 142 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
105 | { | 143 | { |
106 | QString cat; | 144 | QString cat; |
107 | bool isBirthday = true; | 145 | bool isBirthday = true; |
108 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | 146 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { |
109 | isBirthday = false; | 147 | isBirthday = false; |
110 | cat = i18n( "Anniversary" ); | 148 | cat = i18n( "Anniversary" ); |
111 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { | 149 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { |
112 | isBirthday = true; | 150 | isBirthday = true; |
113 | cat = i18n( "Birthday" ); | 151 | cat = i18n( "Birthday" ); |
114 | } else { | 152 | } else { |
115 | qDebug("addAnniversaryNoDup called without fitting category! "); | 153 | qDebug("addAnniversaryNoDup called without fitting category! "); |
116 | return false; | 154 | return false; |
117 | } | 155 | } |
118 | Event * eve; | 156 | Event * eve; |
119 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 157 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
120 | if ( !(eve->categories().contains( cat ) )) | 158 | if ( !(eve->categories().contains( cat ) )) |
121 | continue; | 159 | continue; |
122 | // now we have an event with fitting category | 160 | // now we have an event with fitting category |
123 | if ( eve->dtStart().date() != event->dtStart().date() ) | 161 | if ( eve->dtStart().date() != event->dtStart().date() ) |
124 | continue; | 162 | continue; |
125 | // now we have an event with fitting category+date | 163 | // now we have an event with fitting category+date |
126 | if ( eve->summary() != event->summary() ) | 164 | if ( eve->summary() != event->summary() ) |
127 | continue; | 165 | continue; |
128 | // now we have an event with fitting category+date+summary | 166 | // now we have an event with fitting category+date+summary |
129 | return false; | 167 | return false; |
130 | } | 168 | } |
131 | return addEvent( event ); | 169 | return addEvent( event ); |
132 | 170 | ||
133 | } | 171 | } |
134 | bool CalendarLocal::addEventNoDup( Event *event ) | 172 | bool CalendarLocal::addEventNoDup( Event *event ) |
135 | { | 173 | { |
136 | Event * eve; | 174 | Event * eve; |
137 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 175 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
138 | if ( *eve == *event ) { | 176 | if ( *eve == *event ) { |
139 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 177 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
140 | return false; | 178 | return false; |
141 | } | 179 | } |
142 | } | 180 | } |
143 | return addEvent( event ); | 181 | return addEvent( event ); |
144 | } | 182 | } |
145 | 183 | ||
146 | bool CalendarLocal::addEvent( Event *event ) | 184 | bool CalendarLocal::addEvent( Event *event ) |
147 | { | 185 | { |
148 | insertEvent( event ); | 186 | insertEvent( event ); |
149 | 187 | ||
150 | event->registerObserver( this ); | 188 | event->registerObserver( this ); |
151 | 189 | ||
152 | setModified( true ); | 190 | setModified( true ); |
153 | event->setCalID( mDefaultCalendar ); | 191 | event->setCalID( mDefaultCalendar ); |
154 | event->setCalEnabled( true ); | 192 | event->setCalEnabled( true ); |
155 | 193 | ||
156 | return true; | 194 | return true; |
157 | } | 195 | } |
158 | 196 | ||
159 | void CalendarLocal::deleteEvent( Event *event ) | 197 | void CalendarLocal::deleteEvent( Event *event ) |
160 | { | 198 | { |
161 | if ( mUndoIncidence ) delete mUndoIncidence; | 199 | if ( mUndoIncidence ) delete mUndoIncidence; |
162 | mUndoIncidence = event->clone(); | 200 | mUndoIncidence = event->clone(); |
163 | if ( mEventList.removeRef( event ) ) { | 201 | if ( mEventList.removeRef( event ) ) { |
164 | setModified( true ); | 202 | setModified( true ); |
165 | } | 203 | } |
166 | } | 204 | } |
167 | 205 | ||
168 | 206 | ||
169 | Event *CalendarLocal::event( const QString &uid ) | 207 | Event *CalendarLocal::event( const QString &uid ) |
170 | { | 208 | { |
171 | 209 | ||
172 | Event *event; | 210 | Event *event; |
173 | 211 | ||
174 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 212 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
175 | if ( event->uid() == uid && event->calEnabled() ) { | 213 | if ( event->uid() == uid && event->calEnabled() ) { |
176 | return event; | 214 | return event; |
177 | } | 215 | } |
178 | } | 216 | } |
179 | 217 | ||
180 | return 0; | 218 | return 0; |
181 | } | 219 | } |
182 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 220 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
183 | { | 221 | { |
184 | Todo * eve; | 222 | Todo * eve; |
185 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 223 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
186 | if ( *eve == *todo ) { | 224 | if ( *eve == *todo ) { |
187 | //qDebug("duplicate todo found! not inserted! "); | 225 | //qDebug("duplicate todo found! not inserted! "); |
188 | return false; | 226 | return false; |
189 | } | 227 | } |
190 | } | 228 | } |
191 | return addTodo( todo ); | 229 | return addTodo( todo ); |
192 | } | 230 | } |
193 | bool CalendarLocal::addTodo( Todo *todo ) | 231 | bool CalendarLocal::addTodo( Todo *todo ) |
194 | { | 232 | { |
195 | mTodoList.append( todo ); | 233 | mTodoList.append( todo ); |
196 | 234 | ||
197 | todo->registerObserver( this ); | 235 | todo->registerObserver( this ); |
198 | 236 | ||
199 | // Set up subtask relations | 237 | // Set up subtask relations |
200 | setupRelations( todo ); | 238 | setupRelations( todo ); |
201 | 239 | ||
202 | setModified( true ); | 240 | setModified( true ); |
203 | todo->setCalID( mDefaultCalendar ); | 241 | todo->setCalID( mDefaultCalendar ); |
204 | todo->setCalEnabled( true ); | 242 | todo->setCalEnabled( true ); |
205 | return true; | 243 | return true; |
206 | } | 244 | } |
207 | 245 | ||
208 | void CalendarLocal::deleteTodo( Todo *todo ) | 246 | void CalendarLocal::deleteTodo( Todo *todo ) |
209 | { | 247 | { |
210 | // Handle orphaned children | 248 | // Handle orphaned children |
211 | if ( mUndoIncidence ) delete mUndoIncidence; | 249 | if ( mUndoIncidence ) delete mUndoIncidence; |
212 | removeRelations( todo ); | 250 | removeRelations( todo ); |
213 | mUndoIncidence = todo->clone(); | 251 | mUndoIncidence = todo->clone(); |
214 | 252 | ||
215 | if ( mTodoList.removeRef( todo ) ) { | 253 | if ( mTodoList.removeRef( todo ) ) { |
216 | setModified( true ); | 254 | setModified( true ); |
217 | } | 255 | } |
218 | } | 256 | } |
219 | 257 | ||
220 | QPtrList<Todo> CalendarLocal::rawTodos() | 258 | QPtrList<Todo> CalendarLocal::rawTodos() |
221 | { | 259 | { |
222 | QPtrList<Todo> el; | 260 | QPtrList<Todo> el; |
223 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 261 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
224 | if ( it->calEnabled() ) el.append( it ); | 262 | if ( it->calEnabled() ) el.append( it ); |
225 | return el; | 263 | return el; |
226 | } | 264 | } |
227 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 265 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
228 | { | 266 | { |
229 | Todo *todo; | 267 | Todo *todo; |
230 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 268 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
231 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 269 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
232 | } | 270 | } |
233 | 271 | ||
234 | return 0; | 272 | return 0; |
235 | } | 273 | } |
236 | void CalendarLocal::removeSyncInfo( QString syncProfile) | 274 | void CalendarLocal::removeSyncInfo( QString syncProfile) |
237 | { | 275 | { |
238 | QPtrList<Incidence> all = rawIncidences() ; | 276 | QPtrList<Incidence> all = rawIncidences() ; |
239 | Incidence *inc; | 277 | Incidence *inc; |
240 | for ( inc = all.first(); inc; inc = all.next() ) { | 278 | for ( inc = all.first(); inc; inc = all.next() ) { |
241 | inc->removeID( syncProfile ); | 279 | inc->removeID( syncProfile ); |
242 | } | 280 | } |
243 | if ( syncProfile.isEmpty() ) { | 281 | if ( syncProfile.isEmpty() ) { |
244 | QPtrList<Event> el; | 282 | QPtrList<Event> el; |
245 | Event *todo; | 283 | Event *todo; |
246 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 284 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
247 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 285 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
248 | el.append( todo ); | 286 | el.append( todo ); |
249 | } | 287 | } |
250 | for ( todo = el.first(); todo; todo = el.next() ) { | 288 | for ( todo = el.first(); todo; todo = el.next() ) { |
251 | deleteIncidence ( todo ); | 289 | deleteIncidence ( todo ); |
252 | } | 290 | } |
253 | } else { | 291 | } else { |
254 | Event *lse = event( "last-syncEvent-"+ syncProfile); | 292 | Event *lse = event( "last-syncEvent-"+ syncProfile); |
255 | if ( lse ) | 293 | if ( lse ) |
256 | deleteIncidence ( lse ); | 294 | deleteIncidence ( lse ); |
257 | } | 295 | } |
258 | } | 296 | } |
259 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 297 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
260 | { | 298 | { |
261 | QPtrList<Event> el; | 299 | QPtrList<Event> el; |
262 | Event *todo; | 300 | Event *todo; |
@@ -567,216 +605,230 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | |||
567 | } | 605 | } |
568 | } else { | 606 | } else { |
569 | if ( event->recursOn( qd ) ) | 607 | if ( event->recursOn( qd ) ) |
570 | eventList.append( event ); | 608 | eventList.append( event ); |
571 | } | 609 | } |
572 | } else { | 610 | } else { |
573 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 611 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
574 | eventList.append( event ); | 612 | eventList.append( event ); |
575 | } | 613 | } |
576 | } | 614 | } |
577 | } | 615 | } |
578 | 616 | ||
579 | if ( !sorted ) { | 617 | if ( !sorted ) { |
580 | return eventList; | 618 | return eventList; |
581 | } | 619 | } |
582 | 620 | ||
583 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 621 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
584 | // now, we have to sort it based on dtStart.time() | 622 | // now, we have to sort it based on dtStart.time() |
585 | QPtrList<Event> eventListSorted; | 623 | QPtrList<Event> eventListSorted; |
586 | Event *sortEvent; | 624 | Event *sortEvent; |
587 | for ( event = eventList.first(); event; event = eventList.next() ) { | 625 | for ( event = eventList.first(); event; event = eventList.next() ) { |
588 | sortEvent = eventListSorted.first(); | 626 | sortEvent = eventListSorted.first(); |
589 | int i = 0; | 627 | int i = 0; |
590 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 628 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
591 | { | 629 | { |
592 | i++; | 630 | i++; |
593 | sortEvent = eventListSorted.next(); | 631 | sortEvent = eventListSorted.next(); |
594 | } | 632 | } |
595 | eventListSorted.insert( i, event ); | 633 | eventListSorted.insert( i, event ); |
596 | } | 634 | } |
597 | return eventListSorted; | 635 | return eventListSorted; |
598 | } | 636 | } |
599 | 637 | ||
600 | 638 | ||
601 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 639 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
602 | bool inclusive ) | 640 | bool inclusive ) |
603 | { | 641 | { |
604 | Event *event = 0; | 642 | Event *event = 0; |
605 | 643 | ||
606 | QPtrList<Event> eventList; | 644 | QPtrList<Event> eventList; |
607 | 645 | ||
608 | // Get non-recurring events | 646 | // Get non-recurring events |
609 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 647 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
610 | if ( !event->calEnabled() ) continue; | 648 | if ( !event->calEnabled() ) continue; |
611 | if ( event->doesRecur() ) { | 649 | if ( event->doesRecur() ) { |
612 | QDate rStart = event->dtStart().date(); | 650 | QDate rStart = event->dtStart().date(); |
613 | bool found = false; | 651 | bool found = false; |
614 | if ( inclusive ) { | 652 | if ( inclusive ) { |
615 | if ( rStart >= start && rStart <= end ) { | 653 | if ( rStart >= start && rStart <= end ) { |
616 | // Start date of event is in range. Now check for end date. | 654 | // Start date of event is in range. Now check for end date. |
617 | // if duration is negative, event recurs forever, so do not include it. | 655 | // if duration is negative, event recurs forever, so do not include it. |
618 | if ( event->recurrence()->duration() == 0 ) { // End date set | 656 | if ( event->recurrence()->duration() == 0 ) { // End date set |
619 | QDate rEnd = event->recurrence()->endDate(); | 657 | QDate rEnd = event->recurrence()->endDate(); |
620 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 658 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
621 | found = true; | 659 | found = true; |
622 | } | 660 | } |
623 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 661 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
624 | // TODO: Calculate end date from duration. Should be done in Event | 662 | // TODO: Calculate end date from duration. Should be done in Event |
625 | // For now exclude all events with a duration. | 663 | // For now exclude all events with a duration. |
626 | } | 664 | } |
627 | } | 665 | } |
628 | } else { | 666 | } else { |
629 | bool founOne; | 667 | bool founOne; |
630 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 668 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
631 | if ( founOne ) { | 669 | if ( founOne ) { |
632 | if ( next <= end ) { | 670 | if ( next <= end ) { |
633 | found = true; | 671 | found = true; |
634 | } | 672 | } |
635 | } | 673 | } |
636 | 674 | ||
637 | /* | 675 | /* |
638 | // crap !!! | 676 | // crap !!! |
639 | if ( rStart <= end ) { // Start date not after range | 677 | if ( rStart <= end ) { // Start date not after range |
640 | if ( rStart >= start ) { // Start date within range | 678 | if ( rStart >= start ) { // Start date within range |
641 | found = true; | 679 | found = true; |
642 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 680 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
643 | found = true; | 681 | found = true; |
644 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 682 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
645 | QDate rEnd = event->recurrence()->endDate(); | 683 | QDate rEnd = event->recurrence()->endDate(); |
646 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 684 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
647 | found = true; | 685 | found = true; |
648 | } | 686 | } |
649 | } else { // Duration set | 687 | } else { // Duration set |
650 | // TODO: Calculate end date from duration. Should be done in Event | 688 | // TODO: Calculate end date from duration. Should be done in Event |
651 | // For now include all events with a duration. | 689 | // For now include all events with a duration. |
652 | found = true; | 690 | found = true; |
653 | } | 691 | } |
654 | } | 692 | } |
655 | */ | 693 | */ |
656 | 694 | ||
657 | } | 695 | } |
658 | 696 | ||
659 | if ( found ) eventList.append( event ); | 697 | if ( found ) eventList.append( event ); |
660 | } else { | 698 | } else { |
661 | QDate s = event->dtStart().date(); | 699 | QDate s = event->dtStart().date(); |
662 | QDate e = event->dtEnd().date(); | 700 | QDate e = event->dtEnd().date(); |
663 | 701 | ||
664 | if ( inclusive ) { | 702 | if ( inclusive ) { |
665 | if ( s >= start && e <= end ) { | 703 | if ( s >= start && e <= end ) { |
666 | eventList.append( event ); | 704 | eventList.append( event ); |
667 | } | 705 | } |
668 | } else { | 706 | } else { |
669 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { | 707 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { |
670 | eventList.append( event ); | 708 | eventList.append( event ); |
671 | } | 709 | } |
672 | } | 710 | } |
673 | } | 711 | } |
674 | } | 712 | } |
675 | 713 | ||
676 | return eventList; | 714 | return eventList; |
677 | } | 715 | } |
678 | 716 | ||
679 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 717 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
680 | { | 718 | { |
681 | return rawEventsForDate( qdt.date() ); | 719 | return rawEventsForDate( qdt.date() ); |
682 | } | 720 | } |
683 | 721 | ||
684 | QPtrList<Event> CalendarLocal::rawEvents() | 722 | QPtrList<Event> CalendarLocal::rawEvents() |
685 | { | 723 | { |
686 | QPtrList<Event> el; | 724 | QPtrList<Event> el; |
687 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 725 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
688 | if ( it->calEnabled() ) el.append( it ); | 726 | if ( it->calEnabled() ) el.append( it ); |
689 | return el; | 727 | return el; |
690 | } | 728 | } |
691 | 729 | ||
692 | bool CalendarLocal::addJournal(Journal *journal) | 730 | bool CalendarLocal::addJournal(Journal *journal) |
693 | { | 731 | { |
694 | if ( journal->dtStart().isValid()) | 732 | if ( journal->dtStart().isValid()) |
695 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; | 733 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; |
696 | else | 734 | else |
697 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; | 735 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; |
698 | 736 | ||
699 | mJournalList.append(journal); | 737 | mJournalList.append(journal); |
700 | 738 | ||
701 | journal->registerObserver( this ); | 739 | journal->registerObserver( this ); |
702 | 740 | ||
703 | setModified( true ); | 741 | setModified( true ); |
704 | journal->setCalID( mDefaultCalendar ); | 742 | journal->setCalID( mDefaultCalendar ); |
705 | journal->setCalEnabled( true ); | 743 | journal->setCalEnabled( true ); |
706 | return true; | 744 | return true; |
707 | } | 745 | } |
708 | 746 | ||
709 | void CalendarLocal::deleteJournal( Journal *journal ) | 747 | void CalendarLocal::deleteJournal( Journal *journal ) |
710 | { | 748 | { |
711 | if ( mUndoIncidence ) delete mUndoIncidence; | 749 | if ( mUndoIncidence ) delete mUndoIncidence; |
712 | mUndoIncidence = journal->clone(); | 750 | mUndoIncidence = journal->clone(); |
713 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | 751 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); |
714 | if ( mJournalList.removeRef(journal) ) { | 752 | if ( mJournalList.removeRef(journal) ) { |
715 | setModified( true ); | 753 | setModified( true ); |
716 | } | 754 | } |
717 | } | 755 | } |
718 | 756 | ||
719 | Journal *CalendarLocal::journal( const QDate &date ) | 757 | Journal *CalendarLocal::journal( const QDate &date ) |
720 | { | 758 | { |
721 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; | 759 | // kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; |
722 | 760 | ||
723 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 761 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
724 | if ( it->calEnabled() && it->dtStart().date() == date ) | 762 | if ( it->calEnabled() && it->dtStart().date() == date ) |
725 | return it; | 763 | return it; |
726 | 764 | ||
727 | return 0; | 765 | return 0; |
728 | } | 766 | } |
729 | 767 | ||
730 | Journal *CalendarLocal::journal( const QString &uid ) | 768 | Journal *CalendarLocal::journal( const QString &uid ) |
731 | { | 769 | { |
732 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 770 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
733 | if ( it->calEnabled() && it->uid() == uid ) | 771 | if ( it->calEnabled() && it->uid() == uid ) |
734 | return it; | 772 | return it; |
735 | 773 | ||
736 | return 0; | 774 | return 0; |
737 | } | 775 | } |
738 | 776 | ||
739 | QPtrList<Journal> CalendarLocal::journals() | 777 | QPtrList<Journal> CalendarLocal::journals() |
740 | { | 778 | { |
741 | QPtrList<Journal> el; | 779 | QPtrList<Journal> el; |
742 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 780 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
743 | if ( it->calEnabled() ) el.append( it ); | 781 | if ( it->calEnabled() ) el.append( it ); |
744 | return el; | 782 | return el; |
745 | } | 783 | } |
746 | 784 | ||
747 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) | 785 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) |
748 | { | 786 | { |
749 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 787 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
750 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 788 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
751 | 789 | ||
752 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 790 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
753 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 791 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
754 | 792 | ||
755 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 793 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
756 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 794 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
757 | 795 | ||
758 | } | 796 | } |
797 | |||
798 | void CalendarLocal::setReadOnly( int id, bool enable ) | ||
799 | { | ||
800 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | ||
801 | if ( it->calID() == id ) it->setReadOnly( enable ); | ||
802 | |||
803 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | ||
804 | if ( it->calID() == id ) it->setReadOnly( enable ); | ||
805 | |||
806 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | ||
807 | if ( it->calID() == id ) it->setReadOnly( enable ); | ||
808 | |||
809 | } | ||
810 | |||
759 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) | 811 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) |
760 | { | 812 | { |
761 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 813 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
762 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 814 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
763 | 815 | ||
764 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 816 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
765 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 817 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
766 | 818 | ||
767 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 819 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
768 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); | 820 | if ( it->calID() == id ) it->setAlarmEnabled( enable ); |
769 | 821 | ||
770 | } | 822 | } |
771 | void CalendarLocal::setDefaultCalendarEnabledOnly() | 823 | void CalendarLocal::setDefaultCalendarEnabledOnly() |
772 | { | 824 | { |
773 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 825 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
774 | it->setCalEnabled( it->calID() == mDefaultCalendar ); | 826 | it->setCalEnabled( it->calID() == mDefaultCalendar ); |
775 | 827 | ||
776 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) | 828 | for ( Event *it = mEventList.first(); it; it = mEventList.next() ) |
777 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 829 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
778 | 830 | ||
779 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 831 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
780 | it->setCalEnabled( it->calID() == mDefaultCalendar); | 832 | it->setCalEnabled( it->calID() == mDefaultCalendar); |
781 | 833 | ||
782 | } | 834 | } |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index b25fcbe..65f6aa7 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -1,221 +1,223 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | #ifndef KCAL_CALENDARLOCAL_H | 22 | #ifndef KCAL_CALENDARLOCAL_H |
23 | #define KCAL_CALENDARLOCAL_H | 23 | #define KCAL_CALENDARLOCAL_H |
24 | 24 | ||
25 | #include "calendar.h" | 25 | #include "calendar.h" |
26 | 26 | ||
27 | namespace KCal { | 27 | namespace KCal { |
28 | 28 | ||
29 | class CalFormat; | 29 | class CalFormat; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | This class provides a calendar stored as a local file. | 32 | This class provides a calendar stored as a local file. |
33 | */ | 33 | */ |
34 | class CalendarLocal : public Calendar | 34 | class CalendarLocal : public Calendar |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | /** | 37 | /** |
38 | Constructs a new calendar, with variables initialized to sane values. | 38 | Constructs a new calendar, with variables initialized to sane values. |
39 | */ | 39 | */ |
40 | CalendarLocal(); | 40 | CalendarLocal(); |
41 | /** | 41 | /** |
42 | Constructs a new calendar, with variables initialized to sane values. | 42 | Constructs a new calendar, with variables initialized to sane values. |
43 | */ | 43 | */ |
44 | CalendarLocal( const QString &timeZoneId ); | 44 | CalendarLocal( const QString &timeZoneId ); |
45 | ~CalendarLocal(); | 45 | ~CalendarLocal(); |
46 | 46 | void addCalendar( Calendar* ); | |
47 | bool addCalendarFile( QString name, int id ); | ||
47 | /** | 48 | /** |
48 | Loads a calendar on disk in vCalendar or iCalendar format into the current | 49 | Loads a calendar on disk in vCalendar or iCalendar format into the current |
49 | calendar. Any information already present is lost. | 50 | calendar. Any information already present is lost. |
50 | @return true, if successfull, false on error. | 51 | @return true, if successfull, false on error. |
51 | @param fileName the name of the calendar on disk. | 52 | @param fileName the name of the calendar on disk. |
52 | */ | 53 | */ |
53 | bool load( const QString &fileName ); | 54 | bool load( const QString &fileName ); |
54 | /** | 55 | /** |
55 | Writes out the calendar to disk in the specified \a format. | 56 | Writes out the calendar to disk in the specified \a format. |
56 | CalendarLocal takes ownership of the CalFormat object. | 57 | CalendarLocal takes ownership of the CalFormat object. |
57 | @return true, if successfull, false on error. | 58 | @return true, if successfull, false on error. |
58 | @param fileName the name of the file | 59 | @param fileName the name of the file |
59 | */ | 60 | */ |
60 | bool save( const QString &fileName, CalFormat *format = 0 ); | 61 | bool save( const QString &fileName, CalFormat *format = 0 ); |
61 | 62 | ||
62 | /** | 63 | /** |
63 | Clears out the current calendar, freeing all used memory etc. etc. | 64 | Clears out the current calendar, freeing all used memory etc. etc. |
64 | */ | 65 | */ |
65 | void close(); | 66 | void close(); |
66 | 67 | ||
67 | void save() {} | 68 | void save() {} |
68 | 69 | ||
69 | /** | 70 | /** |
70 | Add Event to calendar. | 71 | Add Event to calendar. |
71 | */ | 72 | */ |
72 | void removeSyncInfo( QString syncProfile); | 73 | void removeSyncInfo( QString syncProfile); |
73 | bool addAnniversaryNoDup( Event *event ); | 74 | bool addAnniversaryNoDup( Event *event ); |
74 | bool addEventNoDup( Event *event ); | 75 | bool addEventNoDup( Event *event ); |
75 | bool addEvent( Event *event ); | 76 | bool addEvent( Event *event ); |
76 | /** | 77 | /** |
77 | Deletes an event from this calendar. | 78 | Deletes an event from this calendar. |
78 | */ | 79 | */ |
79 | void deleteEvent( Event *event ); | 80 | void deleteEvent( Event *event ); |
80 | 81 | ||
81 | /** | 82 | /** |
82 | Retrieves an event on the basis of the unique string ID. | 83 | Retrieves an event on the basis of the unique string ID. |
83 | */ | 84 | */ |
84 | Event *event( const QString &uid ); | 85 | Event *event( const QString &uid ); |
85 | /** | 86 | /** |
86 | Return unfiltered list of all events in calendar. | 87 | Return unfiltered list of all events in calendar. |
87 | */ | 88 | */ |
88 | QPtrList<Event> rawEvents(); | 89 | QPtrList<Event> rawEvents(); |
89 | QPtrList<Event> getExternLastSyncEvents(); | 90 | QPtrList<Event> getExternLastSyncEvents(); |
90 | /** | 91 | /** |
91 | Add a todo to the todolist. | 92 | Add a todo to the todolist. |
92 | */ | 93 | */ |
93 | bool addTodo( Todo *todo ); | 94 | bool addTodo( Todo *todo ); |
94 | bool addTodoNoDup( Todo *todo ); | 95 | bool addTodoNoDup( Todo *todo ); |
95 | /** | 96 | /** |
96 | Remove a todo from the todolist. | 97 | Remove a todo from the todolist. |
97 | */ | 98 | */ |
98 | void deleteTodo( Todo * ); | 99 | void deleteTodo( Todo * ); |
99 | /** | 100 | /** |
100 | Searches todolist for an event with this unique string identifier, | 101 | Searches todolist for an event with this unique string identifier, |
101 | returns a pointer or null. | 102 | returns a pointer or null. |
102 | */ | 103 | */ |
103 | Todo *todo( const QString &uid ); | 104 | Todo *todo( const QString &uid ); |
104 | /** | 105 | /** |
105 | Return list of all todos. | 106 | Return list of all todos. |
106 | */ | 107 | */ |
107 | QPtrList<Todo> rawTodos(); | 108 | QPtrList<Todo> rawTodos(); |
108 | /** | 109 | /** |
109 | Returns list of todos due on the specified date. | 110 | Returns list of todos due on the specified date. |
110 | */ | 111 | */ |
111 | QPtrList<Todo> todos( const QDate &date ); | 112 | QPtrList<Todo> todos( const QDate &date ); |
112 | /** | 113 | /** |
113 | Return list of all todos. | 114 | Return list of all todos. |
114 | 115 | ||
115 | Workaround because compiler does not recognize function of base class. | 116 | Workaround because compiler does not recognize function of base class. |
116 | */ | 117 | */ |
117 | QPtrList<Todo> todos() { return Calendar::todos(); } | 118 | QPtrList<Todo> todos() { return Calendar::todos(); } |
118 | 119 | ||
119 | /** | 120 | /** |
120 | Add a Journal entry to calendar. | 121 | Add a Journal entry to calendar. |
121 | */ | 122 | */ |
122 | bool addJournal( Journal * ); | 123 | bool addJournal( Journal * ); |
123 | /** | 124 | /** |
124 | Remove a Journal from the calendar. | 125 | Remove a Journal from the calendar. |
125 | */ | 126 | */ |
126 | void deleteJournal( Journal * ); | 127 | void deleteJournal( Journal * ); |
127 | /** | 128 | /** |
128 | Return Journal for given date. | 129 | Return Journal for given date. |
129 | */ | 130 | */ |
130 | Journal *journal( const QDate & ); | 131 | Journal *journal( const QDate & ); |
131 | /** | 132 | /** |
132 | Return Journal with given UID. | 133 | Return Journal with given UID. |
133 | */ | 134 | */ |
134 | Journal *journal( const QString &uid ); | 135 | Journal *journal( const QString &uid ); |
135 | /** | 136 | /** |
136 | Return list of all Journals stored in calendar. | 137 | Return list of all Journals stored in calendar. |
137 | */ | 138 | */ |
138 | QPtrList<Journal> journals(); | 139 | QPtrList<Journal> journals(); |
139 | 140 | ||
140 | /** | 141 | /** |
141 | Return all alarms, which ocur in the given time interval. | 142 | Return all alarms, which ocur in the given time interval. |
142 | */ | 143 | */ |
143 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); | 144 | Alarm::List alarms( const QDateTime &from, const QDateTime &to ); |
144 | 145 | ||
145 | /** | 146 | /** |
146 | Return all alarms, which ocur before given date. | 147 | Return all alarms, which ocur before given date. |
147 | */ | 148 | */ |
148 | Alarm::List alarmsTo( const QDateTime &to ); | 149 | Alarm::List alarmsTo( const QDateTime &to ); |
149 | 150 | ||
150 | QDateTime nextAlarm( int daysTo ) ; | 151 | QDateTime nextAlarm( int daysTo ) ; |
151 | QDateTime nextAlarmEventDateTime() const; | 152 | QDateTime nextAlarmEventDateTime() const; |
152 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; | 153 | void checkAlarmForIncidence( Incidence *, bool deleted ) ; |
153 | void registerAlarm(); | 154 | void registerAlarm(); |
154 | void deRegisterAlarm(); | 155 | void deRegisterAlarm(); |
155 | QString getAlarmNotification(); | 156 | QString getAlarmNotification(); |
156 | QString nextSummary() const ; | 157 | QString nextSummary() const ; |
157 | /** | 158 | /** |
158 | This method should be called whenever a Event is modified directly | 159 | This method should be called whenever a Event is modified directly |
159 | via it's pointer. It makes sure that the calendar is internally | 160 | via it's pointer. It makes sure that the calendar is internally |
160 | consistent. | 161 | consistent. |
161 | */ | 162 | */ |
162 | void update( IncidenceBase *incidence ); | 163 | void update( IncidenceBase *incidence ); |
163 | 164 | ||
164 | /** | 165 | /** |
165 | Builds and then returns a list of all events that match for the | 166 | Builds and then returns a list of all events that match for the |
166 | date specified. useful for dayView, etc. etc. | 167 | date specified. useful for dayView, etc. etc. |
167 | */ | 168 | */ |
168 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); | 169 | QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); |
169 | /** | 170 | /** |
170 | Get unfiltered events for date \a qdt. | 171 | Get unfiltered events for date \a qdt. |
171 | */ | 172 | */ |
172 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); | 173 | QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); |
173 | /** | 174 | /** |
174 | Get unfiltered events in a range of dates. If inclusive is set to true, | 175 | Get unfiltered events in a range of dates. If inclusive is set to true, |
175 | only events are returned, which are completely included in the range. | 176 | only events are returned, which are completely included in the range. |
176 | */ | 177 | */ |
177 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, | 178 | QPtrList<Event> rawEvents( const QDate &start, const QDate &end, |
178 | bool inclusive = false ); | 179 | bool inclusive = false ); |
179 | Todo *todo( QString, QString ); | 180 | Todo *todo( QString, QString ); |
180 | Event *event( QString, QString ); | 181 | Event *event( QString, QString ); |
181 | 182 | ||
182 | 183 | public slots: | |
183 | void setCalendarEnabled( int id, bool enable ); | 184 | void setCalendarEnabled( int id, bool enable ); |
184 | void setAlarmEnabled( int id, bool enable ); | 185 | void setAlarmEnabled( int id, bool enable ); |
186 | void setReadOnly( int id, bool enable ); | ||
185 | void setDefaultCalendarEnabledOnly(); | 187 | void setDefaultCalendarEnabledOnly(); |
186 | 188 | ||
187 | protected: | 189 | protected: |
188 | 190 | ||
189 | // Event* mNextAlarmEvent; | 191 | // Event* mNextAlarmEvent; |
190 | QString mNextSummary; | 192 | QString mNextSummary; |
191 | QString mNextAlarmEventDateTimeString; | 193 | QString mNextAlarmEventDateTimeString; |
192 | QString mLastAlarmNotificationString; | 194 | QString mLastAlarmNotificationString; |
193 | QDateTime mNextAlarmEventDateTime; | 195 | QDateTime mNextAlarmEventDateTime; |
194 | QDateTime mNextAlarmDateTime; | 196 | QDateTime mNextAlarmDateTime; |
195 | void reInitAlarmSettings(); | 197 | void reInitAlarmSettings(); |
196 | 198 | ||
197 | /** Notification function of IncidenceBase::Observer. */ | 199 | /** Notification function of IncidenceBase::Observer. */ |
198 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } | 200 | void incidenceUpdated( IncidenceBase *i ) { update( i ); } |
199 | 201 | ||
200 | /** inserts an event into its "proper place" in the calendar. */ | 202 | /** inserts an event into its "proper place" in the calendar. */ |
201 | void insertEvent( Event *event ); | 203 | void insertEvent( Event *event ); |
202 | 204 | ||
203 | /** Append alarms of incidence in interval to list of alarms. */ | 205 | /** Append alarms of incidence in interval to list of alarms. */ |
204 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, | 206 | void appendAlarms( Alarm::List &alarms, Incidence *incidence, |
205 | const QDateTime &from, const QDateTime &to ); | 207 | const QDateTime &from, const QDateTime &to ); |
206 | 208 | ||
207 | /** Append alarms of recurring events in interval to list of alarms. */ | 209 | /** Append alarms of recurring events in interval to list of alarms. */ |
208 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, | 210 | void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, |
209 | const QDateTime &from, const QDateTime &to ); | 211 | const QDateTime &from, const QDateTime &to ); |
210 | 212 | ||
211 | private: | 213 | private: |
212 | void init(); | 214 | void init(); |
213 | 215 | ||
214 | QPtrList<Event> mEventList; | 216 | QPtrList<Event> mEventList; |
215 | QPtrList<Todo> mTodoList; | 217 | QPtrList<Todo> mTodoList; |
216 | QPtrList<Journal> mJournalList; | 218 | QPtrList<Journal> mJournalList; |
217 | }; | 219 | }; |
218 | 220 | ||
219 | } | 221 | } |
220 | 222 | ||
221 | #endif | 223 | #endif |