author | zautrix <zautrix> | 2005-07-10 20:11:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-10 20:11:56 (UTC) |
commit | f06311e58cb5887fd673eb1c2c48acf7cd987ad9 (patch) (unidiff) | |
tree | 301c74302cdddaa3716d79117023228005ebd265 | |
parent | cb784d21ad22ab72a4e3231974f67816185675fd (diff) | |
download | kdepimpi-f06311e58cb5887fd673eb1c2c48acf7cd987ad9.zip kdepimpi-f06311e58cb5887fd673eb1c2c48acf7cd987ad9.tar.gz kdepimpi-f06311e58cb5887fd673eb1c2c48acf7cd987ad9.tar.bz2 |
smarter faster conflict search
-rw-r--r-- | bin/kdepim/WhatsNew.txt | 1 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 72 | ||||
-rw-r--r-- | libkcal/event.cpp | 20 | ||||
-rw-r--r-- | libkcal/event.h | 1 |
4 files changed, 71 insertions, 23 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 1f06f1e..c0d63e5 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -1,71 +1,72 @@ | |||
1 | Info about the changes in new versions of KDE-Pim/Pi | 1 | Info about the changes in new versions of KDE-Pim/Pi |
2 | 2 | ||
3 | ********** VERSION 2.1.16 ************ | 3 | ********** VERSION 2.1.16 ************ |
4 | 4 | ||
5 | Fixed a problem with the menu bar in KO/Pi and using the "Menu" hardware key on the Zaurus. | 5 | Fixed a problem with the menu bar in KO/Pi and using the "Menu" hardware key on the Zaurus. |
6 | Added columns for datetime in todo view: Last modified, created and last modified subtodo | 6 | Added columns for datetime in todo view: Last modified, created and last modified subtodo |
7 | Fixed a bug in agenda view displaying recurring multiday events which are longer than two days. | 7 | Fixed a bug in agenda view displaying recurring multiday events which are longer than two days. |
8 | Made conflict detection up to 4 times faster. | ||
8 | 9 | ||
9 | ********** VERSION 2.1.15 ************ | 10 | ********** VERSION 2.1.15 ************ |
10 | 11 | ||
11 | Fixed two layout problems on the Z: | 12 | Fixed two layout problems on the Z: |
12 | Made the with of the newly added buttons on the Quick-Todo smaller. | 13 | Made the with of the newly added buttons on the Quick-Todo smaller. |
13 | Made listweek layout in 2 columns on the Z760 in portait screen and full menubar visible. | 14 | Made listweek layout in 2 columns on the Z760 in portait screen and full menubar visible. |
14 | 15 | ||
15 | 16 | ||
16 | ********** VERSION 2.1.14 ************ | 17 | ********** VERSION 2.1.14 ************ |
17 | 18 | ||
18 | Added some buttons to the KO/Pi Quick-todo line to make it possible to quickly access some todo view layout settings like display all flat/open/close and hide/show running/done. | 19 | Added some buttons to the KO/Pi Quick-todo line to make it possible to quickly access some todo view layout settings like display all flat/open/close and hide/show running/done. |
19 | Added a button to add a subtodo quickly. | 20 | Added a button to add a subtodo quickly. |
20 | 21 | ||
21 | Added a possibility to search for conflicting events. (In the Action menu. Keyboard shortcut "q", shift+q or ctrl +q ). | 22 | Added a possibility to search for conflicting events. (In the Action menu. Keyboard shortcut "q", shift+q or ctrl +q ). |
22 | Added an option to change the layout of the list week to column mode. | 23 | Added an option to change the layout of the list week to column mode. |
23 | 24 | ||
24 | Fixed some usability problems in pi-sync mode by adding some progress information about file transfer. | 25 | Fixed some usability problems in pi-sync mode by adding some progress information about file transfer. |
25 | 26 | ||
26 | Fixed pi-sync problems with the new multi calendar feature. | 27 | Fixed pi-sync problems with the new multi calendar feature. |
27 | Now pi-sync behaviour should be: | 28 | Now pi-sync behaviour should be: |
28 | 1) Local sends file request ( as usual ) | 29 | 1) Local sends file request ( as usual ) |
29 | 2) Remote sends file which contains data of all enabled ( the calendar where the "eye" column is checked ) calendars. | 30 | 2) Remote sends file which contains data of all enabled ( the calendar where the "eye" column is checked ) calendars. |
30 | 3) Local syncs with data, adds new entries to default calendar and sends file back ( as usual ). | 31 | 3) Local syncs with data, adds new entries to default calendar and sends file back ( as usual ). |
31 | If the data which local receives contains entries which are on disabled calendars on local this entries are updated and not added as duplicates to the default calendar. | 32 | If the data which local receives contains entries which are on disabled calendars on local this entries are updated and not added as duplicates to the default calendar. |
32 | 4) Remote updates the data and adds new entries to default calendar. Readonly entries are not changed on remote. | 33 | 4) Remote updates the data and adds new entries to default calendar. Readonly entries are not changed on remote. |
33 | If the data which remote receives contains entries which are on disabled calendars on remote this entries are updated and not added as duplicates to the default calendar. | 34 | If the data which remote receives contains entries which are on disabled calendars on remote this entries are updated and not added as duplicates to the default calendar. |
34 | 35 | ||
35 | Summary: | 36 | Summary: |
36 | No new item ( new created after the last sync ) in a disabled calendar is propagated to the sync partner. Readonly items are synced and added/changed on the sync partner if it is not readonly on the sync partner. | 37 | No new item ( new created after the last sync ) in a disabled calendar is propagated to the sync partner. Readonly items are synced and added/changed on the sync partner if it is not readonly on the sync partner. |
37 | If you have different calendars on remote and local and some of them disabled you may get some "strange" bahaviour. | 38 | If you have different calendars on remote and local and some of them disabled you may get some "strange" bahaviour. |
38 | Well, the syncing has become quite complicated ... you should have no problems if you enable all calendars. | 39 | Well, the syncing has become quite complicated ... you should have no problems if you enable all calendars. |
39 | 40 | ||
40 | ********** VERSION 2.1.13 ************ | 41 | ********** VERSION 2.1.13 ************ |
41 | 42 | ||
42 | Fixed a problem in KA/Pi search. | 43 | Fixed a problem in KA/Pi search. |
43 | Fixed some minor problems in KO/Pi. | 44 | Fixed some minor problems in KO/Pi. |
44 | Added calendar selection possibility to the todo view popup and to the event/todo/journal editor. | 45 | Added calendar selection possibility to the todo view popup and to the event/todo/journal editor. |
45 | 46 | ||
46 | Fixed memory usage problems in KA/Pi: | 47 | Fixed memory usage problems in KA/Pi: |
47 | When loading data KA/Pi did load the file data twice. | 48 | When loading data KA/Pi did load the file data twice. |
48 | Example: | 49 | Example: |
49 | A 600k file did consume 1200k memory during loading process. | 50 | A 600k file did consume 1200k memory during loading process. |
50 | This is fixed, it does now consume only 600k during loading process. | 51 | This is fixed, it does now consume only 600k during loading process. |
51 | When saving data KA/Pi did consume a lot of memory for the data parsing during the save process. | 52 | When saving data KA/Pi did consume a lot of memory for the data parsing during the save process. |
52 | This is fixed. | 53 | This is fixed. |
53 | Example: | 54 | Example: |
54 | Before saving a 600k file KA/Pi did consume 21.7 Meg of Ram. | 55 | Before saving a 600k file KA/Pi did consume 21.7 Meg of Ram. |
55 | When saving KA/Pi did consume 28.6 Meg of Ram. That causes a crash on the Zaurus because there was no memeory left in the system. | 56 | When saving KA/Pi did consume 28.6 Meg of Ram. That causes a crash on the Zaurus because there was no memeory left in the system. |
56 | Now KA/Pi is consuming on saving the same data 22.0 Meg of Ram during the save process. | 57 | Now KA/Pi is consuming on saving the same data 22.0 Meg of Ram during the save process. |
57 | Note: The memory usage of KA/Pi after the data is loaded/saved has not changed. | 58 | Note: The memory usage of KA/Pi after the data is loaded/saved has not changed. |
58 | The saving of data may be a bit slower now. | 59 | The saving of data may be a bit slower now. |
59 | 60 | ||
60 | Fixed memory usage problems in KO/Pi: | 61 | Fixed memory usage problems in KO/Pi: |
61 | When KO/Pi did save the data to file, it did not release the used buffers after saving. | 62 | When KO/Pi did save the data to file, it did not release the used buffers after saving. |
62 | The used buffer was released after saving the next time, but there was new buffer space allocated again on that save operation. | 63 | The used buffer was released after saving the next time, but there was new buffer space allocated again on that save operation. |
63 | This is fixed. | 64 | This is fixed. |
64 | Example: | 65 | Example: |
65 | When saving a 400k file KO/Pi do now use 400k less memory now. | 66 | When saving a 400k file KO/Pi do now use 400k less memory now. |
66 | 67 | ||
67 | Optimized memory usage in KO/Pi Agenda view: | 68 | Optimized memory usage in KO/Pi Agenda view: |
68 | KO/Pi is storing some paint information in extra buffers for faster repainting of the agenda view. | 69 | KO/Pi is storing some paint information in extra buffers for faster repainting of the agenda view. |
69 | These buffers were not made smaller (i.e. downsized) because of performance reasons. | 70 | These buffers were not made smaller (i.e. downsized) because of performance reasons. |
70 | The handling of these buffers are now much smarter: | 71 | The handling of these buffers are now much smarter: |
71 | Two (of six) buffers are removed completely. | 72 | Two (of six) buffers are removed completely. |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a9e402e..427d71b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -598,197 +598,214 @@ void CalendarView::init() | |||
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | void CalendarView::nextConflict( bool all, bool allday ) | 660 | void CalendarView::nextConflict( bool all, bool allday ) |
661 | { | 661 | { |
662 | 662 | static bool block = false; | |
663 | if ( block ) return; | ||
664 | block = true; | ||
663 | QPtrList<Event> testlist = mCalendar->events(); | 665 | QPtrList<Event> testlist = mCalendar->events(); |
664 | Event * test = testlist.first(); | 666 | Event * test = testlist.first(); |
665 | while ( test ) { | 667 | while ( test ) { |
666 | test->setTagged( false ); | 668 | test->setTagged( false ); |
667 | test = testlist.next(); | 669 | test = testlist.next(); |
668 | } | 670 | } |
669 | QTime st ( 0,0,0); | 671 | QTime st ( 0,0,0); |
670 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
671 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 673 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
672 | //qDebug("time %s ", st.toString().latin1()); | 674 | //qDebug("time %s ", st.toString().latin1()); |
673 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
674 | QDateTime conflict; | 676 | QDateTime conflict; |
675 | QDateTime retVal; | 677 | QDateTime retVal; |
676 | bool found = false; | 678 | bool found = false; |
677 | Event * cE = 0; | 679 | Event * cE = 0; |
678 | Event * cE2 = 0; | 680 | Event * cE2 = 0; |
679 | QPtrList<Event> testlist2 = testlist; | 681 | QPtrList<Event> testlist2 = testlist; |
680 | test = testlist.first(); | 682 | test = testlist.first(); |
681 | bool skip = false; | 683 | bool skip = false; |
682 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
685 | //QTime tm; | ||
686 | //tm.start(); | ||
683 | while ( test ) { | 687 | while ( test ) { |
684 | qApp->processEvents(); | 688 | qApp->processEvents(); |
685 | skip = false; | 689 | skip = false; |
686 | if ( !all ) skip = ( allday != test->doesFloat() ); | 690 | if ( !all ) skip = ( allday != test->doesFloat() ); |
687 | if ( !skip ) { | 691 | if ( !skip ) { |
692 | if ( found ) | ||
693 | skip = !test->matchTime( &startDT, &conflict ); | ||
694 | else | ||
695 | skip = !test->matchTime( &startDT, 0 ); | ||
696 | } | ||
697 | if ( !skip ) { | ||
688 | Event * test2 = testlist2.first(); | 698 | Event * test2 = testlist2.first(); |
689 | while ( test2 ) { | 699 | while ( test2 ) { |
690 | skip = false; | 700 | skip = test2->isTagged(); |
691 | if ( !all ) skip = ( allday != test2->doesFloat() ); | 701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
702 | if ( !skip ) { | ||
703 | if ( found ) | ||
704 | skip = !test2->matchTime( &startDT, &conflict ); | ||
705 | else | ||
706 | skip = !test2->matchTime( &startDT, 0 ); | ||
707 | } | ||
692 | if ( !skip ) { | 708 | if ( !skip ) { |
693 | if ( !test2->isTagged() ) { | 709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
694 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 710 | //qDebug("overlap "); |
695 | //qDebug("overlap "); | 711 | if ( ! found ) { |
696 | if ( ! found ) { | 712 | if ( retVal >= startDT ) { |
697 | if ( retVal >= startDT ) { | 713 | conflict = retVal; |
698 | conflict = retVal; | 714 | cE = test; |
699 | cE = test; | 715 | cE2 = test2; |
700 | cE2 = test2; | 716 | found = true; |
701 | found = true; | 717 | } |
702 | } | 718 | } else { |
703 | } else { | 719 | if ( retVal >= startDT && retVal < conflict ) { |
704 | if ( retVal >= startDT && retVal < conflict ) { | 720 | conflict = retVal; |
705 | conflict = retVal; | 721 | cE = test; |
706 | cE = test; | 722 | cE2 = test2; |
707 | cE2 = test2; | ||
708 | } | ||
709 | } | 723 | } |
710 | } | 724 | } |
711 | } | 725 | } |
712 | } | 726 | } |
713 | test2 = testlist2.next(); | 727 | test2 = testlist2.next(); |
714 | } | 728 | } |
715 | } | 729 | } |
716 | test->setTagged( true ); | 730 | test->setTagged( true ); |
717 | test = testlist.next(); | 731 | test = testlist.next(); |
718 | } | 732 | } |
733 | //qDebug("Search time : %d", tm.elapsed()); | ||
719 | if ( found ) { | 734 | if ( found ) { |
720 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
721 | mViewManager->showDayView(); | 736 | mViewManager->showDayView(); |
722 | mNavigator->slotDaySelect( conflict.date() ); | 737 | mNavigator->slotDaySelect( conflict.date() ); |
723 | int hour = conflict.time().hour(); | 738 | int hour = conflict.time().hour(); |
724 | mViewManager->agendaView()->setStartHour( hour ); | 739 | mViewManager->agendaView()->setStartHour( hour ); |
725 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
741 | block = false; | ||
726 | return; | 742 | return; |
727 | } | 743 | } |
728 | 744 | ||
729 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 745 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
730 | qDebug("No conflict found "); | 746 | qDebug("No conflict found "); |
747 | block = false; | ||
731 | return; | 748 | return; |
732 | } | 749 | } |
733 | 750 | ||
734 | void CalendarView::conflictAll() | 751 | void CalendarView::conflictAll() |
735 | { | 752 | { |
736 | nextConflict ( true, true ); | 753 | nextConflict ( true, true ); |
737 | } | 754 | } |
738 | void CalendarView::conflictAllday() | 755 | void CalendarView::conflictAllday() |
739 | { | 756 | { |
740 | nextConflict ( false, true ); | 757 | nextConflict ( false, true ); |
741 | } | 758 | } |
742 | void CalendarView::conflictNotAll() | 759 | void CalendarView::conflictNotAll() |
743 | { | 760 | { |
744 | nextConflict ( false, false ); | 761 | nextConflict ( false, false ); |
745 | } | 762 | } |
746 | 763 | ||
747 | void CalendarView::setCalReadOnly( int id, bool readO ) | 764 | void CalendarView::setCalReadOnly( int id, bool readO ) |
748 | { | 765 | { |
749 | if ( readO ) { | 766 | if ( readO ) { |
750 | emit save(); | 767 | emit save(); |
751 | } | 768 | } |
752 | mCalendar->setReadOnly( id, readO ); | 769 | mCalendar->setReadOnly( id, readO ); |
753 | } | 770 | } |
754 | void CalendarView::setScrollBarStep(int val ) | 771 | void CalendarView::setScrollBarStep(int val ) |
755 | { | 772 | { |
756 | #ifdef DESKTOP_VERSION | 773 | #ifdef DESKTOP_VERSION |
757 | mDateScrollBar->setLineStep ( val ); | 774 | mDateScrollBar->setLineStep ( val ); |
758 | #endif | 775 | #endif |
759 | } | 776 | } |
760 | void CalendarView::scrollBarValue(int val ) | 777 | void CalendarView::scrollBarValue(int val ) |
761 | { | 778 | { |
762 | #ifdef DESKTOP_VERSION | 779 | #ifdef DESKTOP_VERSION |
763 | if ( QApplication::desktop()->width() < 800 ) return; | 780 | if ( QApplication::desktop()->width() < 800 ) return; |
764 | static bool block = false; | 781 | static bool block = false; |
765 | if ( block ) return; | 782 | if ( block ) return; |
766 | block = true; | 783 | block = true; |
767 | int count = mNavigator->selectedDates().count(); | 784 | int count = mNavigator->selectedDates().count(); |
768 | int day = mNavigator->selectedDates().first().dayOfYear(); | 785 | int day = mNavigator->selectedDates().first().dayOfYear(); |
769 | int stepdays = val; | 786 | int stepdays = val; |
770 | if ( mDateScrollBar->lineStep () <= count ) { | 787 | if ( mDateScrollBar->lineStep () <= count ) { |
771 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
772 | //qDebug("VAL %d ",val ); | 789 | //qDebug("VAL %d ",val ); |
773 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
774 | stepdays = day+stepdays; | 791 | stepdays = day+stepdays; |
775 | if ( stepdays < 0 ) stepdays = 0; | 792 | if ( stepdays < 0 ) stepdays = 0; |
776 | } | 793 | } |
777 | if ( stepdays == day ) { | 794 | if ( stepdays == day ) { |
778 | block = false; | 795 | block = false; |
779 | return; | 796 | return; |
780 | } | 797 | } |
781 | int year = mNavigator->selectedDates().first().year(); | 798 | int year = mNavigator->selectedDates().first().year(); |
782 | QDate d ( year,1,1 ); | 799 | QDate d ( year,1,1 ); |
783 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
784 | block = false; | 801 | block = false; |
785 | #endif | 802 | #endif |
786 | 803 | ||
787 | } | 804 | } |
788 | void CalendarView::updateView(const QDate &start, const QDate &end) | 805 | void CalendarView::updateView(const QDate &start, const QDate &end) |
789 | { | 806 | { |
790 | #ifdef DESKTOP_VERSION | 807 | #ifdef DESKTOP_VERSION |
791 | if ( ! mDateScrollBar->draggingSlider () ) { | 808 | if ( ! mDateScrollBar->draggingSlider () ) { |
792 | int dof = start.dayOfYear(); | 809 | int dof = start.dayOfYear(); |
793 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
794 | if ( dof != mDateScrollBar->value() ) { | 811 | if ( dof != mDateScrollBar->value() ) { |
@@ -2711,139 +2728,148 @@ void CalendarView::eventDeleted() | |||
2711 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2728 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2712 | { | 2729 | { |
2713 | changeIncidenceDisplay((Incidence *)which, action); | 2730 | changeIncidenceDisplay((Incidence *)which, action); |
2714 | mDateNavigator->updateView(); //LR | 2731 | mDateNavigator->updateView(); //LR |
2715 | //mDialogManager->updateSearchDialog(); | 2732 | //mDialogManager->updateSearchDialog(); |
2716 | 2733 | ||
2717 | if (which) { | 2734 | if (which) { |
2718 | mViewManager->updateWNview(); | 2735 | mViewManager->updateWNview(); |
2719 | //mTodoList->updateView(); | 2736 | //mTodoList->updateView(); |
2720 | } | 2737 | } |
2721 | 2738 | ||
2722 | } | 2739 | } |
2723 | 2740 | ||
2724 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2741 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2725 | { | 2742 | { |
2726 | updateUnmanagedViews(); | 2743 | updateUnmanagedViews(); |
2727 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2744 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2728 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2745 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2729 | mCalendar->checkAlarmForIncidence( 0, true ); | 2746 | mCalendar->checkAlarmForIncidence( 0, true ); |
2730 | if ( mEventViewerDialog ) | 2747 | if ( mEventViewerDialog ) |
2731 | mEventViewerDialog->hide(); | 2748 | mEventViewerDialog->hide(); |
2732 | } | 2749 | } |
2733 | else | 2750 | else |
2734 | mCalendar->checkAlarmForIncidence( which , false ); | 2751 | mCalendar->checkAlarmForIncidence( which , false ); |
2735 | } | 2752 | } |
2736 | 2753 | ||
2737 | // most of the changeEventDisplays() right now just call the view's | 2754 | // most of the changeEventDisplays() right now just call the view's |
2738 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2755 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2739 | void CalendarView::changeEventDisplay(Event *which, int action) | 2756 | void CalendarView::changeEventDisplay(Event *which, int action) |
2740 | { | 2757 | { |
2741 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2758 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2742 | changeIncidenceDisplay((Incidence *)which, action); | 2759 | changeIncidenceDisplay((Incidence *)which, action); |
2743 | static bool clearallviews = false; | 2760 | static bool clearallviews = false; |
2744 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2761 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2745 | if ( clearallviews ) { | 2762 | if ( clearallviews ) { |
2746 | clearAllViews(); | 2763 | clearAllViews(); |
2747 | clearallviews = false; | 2764 | clearallviews = false; |
2748 | } | 2765 | } |
2749 | return; | 2766 | return; |
2750 | } | 2767 | } |
2751 | clearallviews = true; | 2768 | clearallviews = true; |
2752 | mDateNavigator->updateView(); | 2769 | mDateNavigator->updateView(); |
2753 | //mDialogManager->updateSearchDialog(); | 2770 | //mDialogManager->updateSearchDialog(); |
2754 | if (which) { | 2771 | if (which) { |
2755 | // If there is an event view visible update the display | 2772 | // If there is an event view visible update the display |
2756 | mViewManager->currentView()->changeEventDisplay(which,action); | 2773 | mViewManager->currentView()->changeEventDisplay(which,action); |
2757 | // TODO: check, if update needed | 2774 | // TODO: check, if update needed |
2758 | // if (which->getTodoStatus()) { | 2775 | // if (which->getTodoStatus()) { |
2759 | mTodoList->updateView(); | 2776 | mTodoList->updateView(); |
2760 | if ( action != KOGlobals::EVENTDELETED ) { | 2777 | if ( action != KOGlobals::EVENTDELETED ) { |
2761 | mConflictingEvent = which ; | 2778 | mConflictingEvent = which ; |
2762 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); | 2779 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); |
2763 | } | 2780 | } |
2764 | // } | 2781 | // } |
2765 | } else { | 2782 | } else { |
2766 | mViewManager->currentView()->updateView(); | 2783 | mViewManager->currentView()->updateView(); |
2767 | } | 2784 | } |
2768 | } | 2785 | } |
2769 | void CalendarView::checkConflictForEvent() | 2786 | void CalendarView::checkConflictForEvent() |
2770 | { | 2787 | { |
2771 | 2788 | ||
2772 | if (!KOPrefs::instance()->mConfirm) | 2789 | if (!KOPrefs::instance()->mConfirm) |
2773 | return; | 2790 | return; |
2774 | if ( ! mConflictingEvent ) return; | 2791 | if ( ! mConflictingEvent ) return; |
2775 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 2792 | QDateTime current = QDateTime::currentDateTime(); |
2793 | if ( ! mConflictingEvent->matchTime( ¤t, 0 ) ) { | ||
2794 | mConflictingEvent = 0; | ||
2795 | return; | ||
2796 | } | ||
2776 | QPtrList<Event> testlist = mCalendar->events(); | 2797 | QPtrList<Event> testlist = mCalendar->events(); |
2777 | Event * test = testlist.first(); | 2798 | Event * test = testlist.first(); |
2778 | QDateTime conflict; | 2799 | QDateTime conflict; |
2779 | QDateTime retVal; | 2800 | QDateTime retVal; |
2780 | bool found = false; | 2801 | bool found = false; |
2781 | Event * cE = 0; | 2802 | Event * cE = 0; |
2782 | QDateTime current = QDateTime::currentDateTime(); | 2803 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
2783 | while ( test ) { | 2804 | while ( test ) { |
2784 | qApp->processEvents(); | 2805 | qApp->processEvents(); |
2785 | if ( !test->doesFloat() ) { | 2806 | bool skip = false; |
2807 | if ( found ) | ||
2808 | skip = !test->matchTime( ¤t, &conflict ); | ||
2809 | else | ||
2810 | skip = !test->matchTime( ¤t, 0 ); | ||
2811 | if ( !skip && !test->doesFloat() ) { | ||
2786 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 2812 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2787 | if ( ! found ) { | 2813 | if ( ! found ) { |
2788 | conflict = retVal; | 2814 | conflict = retVal; |
2789 | cE = test; | 2815 | cE = test; |
2790 | } else { | 2816 | } else { |
2791 | if ( retVal < conflict ) { | 2817 | if ( retVal < conflict ) { |
2792 | conflict = retVal; | 2818 | conflict = retVal; |
2793 | cE = test; | 2819 | cE = test; |
2794 | } | 2820 | } |
2795 | } | 2821 | } |
2796 | found = true; | 2822 | found = true; |
2797 | } | 2823 | } |
2798 | } | 2824 | } |
2799 | test = testlist.next(); | 2825 | test = testlist.next(); |
2800 | } | 2826 | } |
2801 | if ( found ) { | 2827 | if ( found ) { |
2802 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 2828 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
2803 | qApp->processEvents(); | 2829 | qApp->processEvents(); |
2804 | int km = KMessageBox::warningContinueCancel(this,mess, | 2830 | int km = KMessageBox::warningContinueCancel(this,mess, |
2805 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2831 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2806 | if ( km != KMessageBox::Continue ) | 2832 | if ( km != KMessageBox::Continue ) |
2807 | return; | 2833 | return; |
2808 | 2834 | ||
2809 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2835 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2810 | mViewManager->showDayView(); | 2836 | mViewManager->showDayView(); |
2811 | mNavigator->slotDaySelect( conflict.date() ); | 2837 | mNavigator->slotDaySelect( conflict.date() ); |
2812 | int hour = conflict.time().hour(); | 2838 | int hour = conflict.time().hour(); |
2813 | mViewManager->agendaView()->setStartHour( hour ); | 2839 | mViewManager->agendaView()->setStartHour( hour ); |
2814 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2840 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2815 | } else | 2841 | } else |
2816 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 2842 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
2817 | mConflictingEvent = 0; | 2843 | mConflictingEvent = 0; |
2818 | return; | 2844 | return; |
2819 | 2845 | ||
2820 | } | 2846 | } |
2821 | 2847 | ||
2822 | void CalendarView::updateTodoViews() | 2848 | void CalendarView::updateTodoViews() |
2823 | { | 2849 | { |
2824 | mTodoList->updateView(); | 2850 | mTodoList->updateView(); |
2825 | mViewManager->currentView()->updateView(); | 2851 | mViewManager->currentView()->updateView(); |
2826 | 2852 | ||
2827 | } | 2853 | } |
2828 | 2854 | ||
2829 | 2855 | ||
2830 | 2856 | ||
2831 | void CalendarView::clearAllViews() | 2857 | void CalendarView::clearAllViews() |
2832 | { | 2858 | { |
2833 | mTodoList->clearList(); | 2859 | mTodoList->clearList(); |
2834 | mViewManager->clearAllViews(); | 2860 | mViewManager->clearAllViews(); |
2835 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2861 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2836 | if ( sd ) { | 2862 | if ( sd ) { |
2837 | KOListView* kol = sd->listview(); | 2863 | KOListView* kol = sd->listview(); |
2838 | if ( kol ) | 2864 | if ( kol ) |
2839 | kol->clearList(); | 2865 | kol->clearList(); |
2840 | } | 2866 | } |
2841 | } | 2867 | } |
2842 | void CalendarView::updateView() | 2868 | void CalendarView::updateView() |
2843 | { | 2869 | { |
2844 | static bool clearallviews = false; | 2870 | static bool clearallviews = false; |
2845 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2871 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2846 | if ( clearallviews ) { | 2872 | if ( clearallviews ) { |
2847 | clearAllViews(); | 2873 | clearAllViews(); |
2848 | clearallviews = false; | 2874 | clearallviews = false; |
2849 | } | 2875 | } |
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 5285559..ad66639 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -110,128 +110,148 @@ void Event::setDtEnd(const QDateTime &dtEnd) | |||
110 | mDtEnd = getEvenTime( dtEnd ); | 110 | mDtEnd = getEvenTime( dtEnd ); |
111 | 111 | ||
112 | setHasEndDate(true); | 112 | setHasEndDate(true); |
113 | setHasDuration(false); | 113 | setHasDuration(false); |
114 | 114 | ||
115 | updated(); | 115 | updated(); |
116 | } | 116 | } |
117 | 117 | ||
118 | QDateTime Event::dtEnd() const | 118 | QDateTime Event::dtEnd() const |
119 | { | 119 | { |
120 | if (hasEndDate()) return mDtEnd; | 120 | if (hasEndDate()) return mDtEnd; |
121 | if (hasDuration()) return dtStart().addSecs(duration()); | 121 | if (hasDuration()) return dtStart().addSecs(duration()); |
122 | 122 | ||
123 | return dtStart(); | 123 | return dtStart(); |
124 | } | 124 | } |
125 | 125 | ||
126 | QString Event::dtEndTimeStr() const | 126 | QString Event::dtEndTimeStr() const |
127 | { | 127 | { |
128 | return KGlobal::locale()->formatTime(mDtEnd.time()); | 128 | return KGlobal::locale()->formatTime(mDtEnd.time()); |
129 | } | 129 | } |
130 | 130 | ||
131 | QString Event::dtEndDateStr(bool shortfmt) const | 131 | QString Event::dtEndDateStr(bool shortfmt) const |
132 | { | 132 | { |
133 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); | 133 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); |
134 | } | 134 | } |
135 | 135 | ||
136 | QString Event::dtEndStr(bool shortfmt) const | 136 | QString Event::dtEndStr(bool shortfmt) const |
137 | { | 137 | { |
138 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); | 138 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); |
139 | } | 139 | } |
140 | 140 | ||
141 | void Event::setHasEndDate(bool b) | 141 | void Event::setHasEndDate(bool b) |
142 | { | 142 | { |
143 | mHasEndDate = b; | 143 | mHasEndDate = b; |
144 | } | 144 | } |
145 | 145 | ||
146 | bool Event::hasEndDate() const | 146 | bool Event::hasEndDate() const |
147 | { | 147 | { |
148 | return mHasEndDate; | 148 | return mHasEndDate; |
149 | } | 149 | } |
150 | 150 | ||
151 | bool Event::isMultiDay() const | 151 | bool Event::isMultiDay() const |
152 | { | 152 | { |
153 | bool multi = !(dtStart().date() == dtEnd().date()); | 153 | bool multi = !(dtStart().date() == dtEnd().date()); |
154 | return multi; | 154 | return multi; |
155 | } | 155 | } |
156 | 156 | ||
157 | void Event::setTransparency(Event::Transparency transparency) | 157 | void Event::setTransparency(Event::Transparency transparency) |
158 | { | 158 | { |
159 | if (mReadOnly) return; | 159 | if (mReadOnly) return; |
160 | mTransparency = transparency; | 160 | mTransparency = transparency; |
161 | updated(); | 161 | updated(); |
162 | } | 162 | } |
163 | 163 | ||
164 | Event::Transparency Event::transparency() const | 164 | Event::Transparency Event::transparency() const |
165 | { | 165 | { |
166 | return mTransparency; | 166 | return mTransparency; |
167 | } | 167 | } |
168 | 168 | ||
169 | void Event::setDuration(int seconds) | 169 | void Event::setDuration(int seconds) |
170 | { | 170 | { |
171 | setHasEndDate(false); | 171 | setHasEndDate(false); |
172 | Incidence::setDuration(seconds); | 172 | Incidence::setDuration(seconds); |
173 | } | 173 | } |
174 | bool Event::matchTime(QDateTime*startDT, QDateTime* endDT) | ||
175 | { | ||
176 | if ( ! doesRecur() ) { | ||
177 | if ( doesFloat() ) { | ||
178 | if ( mDtEnd.addDays( 1 ) < *startDT) | ||
179 | return false; | ||
180 | if ( endDT && mDtStart > * endDT) | ||
181 | return false; | ||
182 | } else { | ||
183 | if ( mDtEnd < *startDT ) | ||
184 | return false; | ||
185 | if ( endDT && mDtStart > * endDT) | ||
186 | return false; | ||
187 | } | ||
188 | } else { | ||
189 | if ( endDT && mDtStart > * endDT) | ||
190 | return false; | ||
191 | } | ||
192 | return true; | ||
193 | } | ||
174 | bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime* startDT ) | 194 | bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime* startDT ) |
175 | { | 195 | { |
176 | if ( testEvent == this ) | 196 | if ( testEvent == this ) |
177 | return false; | 197 | return false; |
178 | if ( ! doesRecur() && !testEvent->doesRecur() ) { | 198 | if ( ! doesRecur() && !testEvent->doesRecur() ) { |
179 | QDateTime te; | 199 | QDateTime te; |
180 | if ( testEvent->doesFloat() ) | 200 | if ( testEvent->doesFloat() ) |
181 | te = testEvent->mDtEnd.addDays( 1 ); | 201 | te = testEvent->mDtEnd.addDays( 1 ); |
182 | else | 202 | else |
183 | te = testEvent->mDtEnd; | 203 | te = testEvent->mDtEnd; |
184 | QDateTime e; | 204 | QDateTime e; |
185 | if ( doesFloat() ) | 205 | if ( doesFloat() ) |
186 | e = mDtEnd.addDays( 1 ); | 206 | e = mDtEnd.addDays( 1 ); |
187 | else | 207 | else |
188 | e = mDtEnd; | 208 | e = mDtEnd; |
189 | if ( mDtStart < te && testEvent->mDtStart < e ) { | 209 | if ( mDtStart < te && testEvent->mDtStart < e ) { |
190 | if ( mDtStart < testEvent->mDtStart ) | 210 | if ( mDtStart < testEvent->mDtStart ) |
191 | *overlapDT = testEvent->mDtStart; | 211 | *overlapDT = testEvent->mDtStart; |
192 | else | 212 | else |
193 | *overlapDT = mDtStart; | 213 | *overlapDT = mDtStart; |
194 | if ( startDT ) | 214 | if ( startDT ) |
195 | return (*overlapDT >= *startDT ); | 215 | return (*overlapDT >= *startDT ); |
196 | return true; | 216 | return true; |
197 | } | 217 | } |
198 | return false; | 218 | return false; |
199 | } | 219 | } |
200 | if ( !doesFloat() && !testEvent->doesFloat() && !isMultiDay() && !testEvent->isMultiDay() ) { | 220 | if ( !doesFloat() && !testEvent->doesFloat() && !isMultiDay() && !testEvent->isMultiDay() ) { |
201 | if ( mDtStart.time() >= testEvent->mDtEnd.time() || testEvent->mDtStart.time() >= mDtEnd.time() ) { | 221 | if ( mDtStart.time() >= testEvent->mDtEnd.time() || testEvent->mDtStart.time() >= mDtEnd.time() ) { |
202 | // no need to test. times mismatch | 222 | // no need to test. times mismatch |
203 | //fprintf(stderr,"timi "); | 223 | //fprintf(stderr,"timi "); |
204 | return false; | 224 | return false; |
205 | } | 225 | } |
206 | } | 226 | } |
207 | Event *nonRecur = 0; | 227 | Event *nonRecur = 0; |
208 | Event *recurEvent = 0; | 228 | Event *recurEvent = 0; |
209 | if ( ! doesRecur() ) { | 229 | if ( ! doesRecur() ) { |
210 | nonRecur = this; | 230 | nonRecur = this; |
211 | recurEvent = testEvent; | 231 | recurEvent = testEvent; |
212 | } | 232 | } |
213 | else if ( !testEvent->doesRecur() ) { | 233 | else if ( !testEvent->doesRecur() ) { |
214 | nonRecur = testEvent; | 234 | nonRecur = testEvent; |
215 | recurEvent = this; | 235 | recurEvent = this; |
216 | } | 236 | } |
217 | if ( nonRecur ) { | 237 | if ( nonRecur ) { |
218 | QDateTime enr; | 238 | QDateTime enr; |
219 | if ( nonRecur->doesFloat() ) | 239 | if ( nonRecur->doesFloat() ) |
220 | enr = nonRecur->mDtEnd.addDays( 1 ); | 240 | enr = nonRecur->mDtEnd.addDays( 1 ); |
221 | else | 241 | else |
222 | enr = nonRecur->mDtEnd; | 242 | enr = nonRecur->mDtEnd; |
223 | if ( enr < recurEvent->mDtStart ) | 243 | if ( enr < recurEvent->mDtStart ) |
224 | return false; | 244 | return false; |
225 | if ( startDT && enr < *startDT ) | 245 | if ( startDT && enr < *startDT ) |
226 | return false; | 246 | return false; |
227 | 247 | ||
228 | int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd ); | 248 | int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd ); |
229 | if ( recurEvent->doesFloat() ) | 249 | if ( recurEvent->doesFloat() ) |
230 | recDuration += 86400; | 250 | recDuration += 86400; |
231 | bool ok = false; | 251 | bool ok = false; |
232 | QDateTime recStart; | 252 | QDateTime recStart; |
233 | if ( startDT ) { | 253 | if ( startDT ) { |
234 | recStart = recurEvent->recurrence()->getPreviousDateTime( startDT->addSecs( 61 ), &ok ); | 254 | recStart = recurEvent->recurrence()->getPreviousDateTime( startDT->addSecs( 61 ), &ok ); |
235 | } | 255 | } |
236 | if ( recStart.isValid() ) { | 256 | if ( recStart.isValid() ) { |
237 | //qDebug("%s start at %s ", startDT-> toString().latin1(), recStart.toString().latin1()); | 257 | //qDebug("%s start at %s ", startDT-> toString().latin1(), recStart.toString().latin1()); |
diff --git a/libkcal/event.h b/libkcal/event.h index e6055a5..2da9770 100644 --- a/libkcal/event.h +++ b/libkcal/event.h | |||
@@ -1,93 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef EVENT_H | 21 | #ifndef EVENT_H |
22 | #define EVENT_H | 22 | #define EVENT_H |
23 | // | 23 | // |
24 | // Event component, representing a VEVENT object | 24 | // Event component, representing a VEVENT object |
25 | // | 25 | // |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | namespace KCal { | 28 | namespace KCal { |
29 | 29 | ||
30 | /** | 30 | /** |
31 | This class provides an Event in the sense of RFC2445. | 31 | This class provides an Event in the sense of RFC2445. |
32 | */ | 32 | */ |
33 | class Event : public Incidence | 33 | class Event : public Incidence |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | enum Transparency { Opaque, Transparent }; | 36 | enum Transparency { Opaque, Transparent }; |
37 | typedef ListBase<Event> List; | 37 | typedef ListBase<Event> List; |
38 | Event(); | 38 | Event(); |
39 | Event(const Event &); | 39 | Event(const Event &); |
40 | ~Event(); | 40 | ~Event(); |
41 | bool matchTime(QDateTime*startDT, QDateTime* endDT); | ||
41 | 42 | ||
42 | QCString type() const { return "Event"; } | 43 | QCString type() const { return "Event"; } |
43 | IncTypeID typeID() const { return eventID; } | 44 | IncTypeID typeID() const { return eventID; } |
44 | 45 | ||
45 | Incidence *clone(); | 46 | Incidence *clone(); |
46 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; | 47 | QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; |
47 | 48 | ||
48 | /** for setting an event's ending date/time with a QDateTime. */ | 49 | /** for setting an event's ending date/time with a QDateTime. */ |
49 | void setDtEnd(const QDateTime &dtEnd); | 50 | void setDtEnd(const QDateTime &dtEnd); |
50 | /** Return the event's ending date/time as a QDateTime. */ | 51 | /** Return the event's ending date/time as a QDateTime. */ |
51 | virtual QDateTime dtEnd() const; | 52 | virtual QDateTime dtEnd() const; |
52 | /** returns an event's end time as a string formatted according to the | 53 | /** returns an event's end time as a string formatted according to the |
53 | users locale settings */ | 54 | users locale settings */ |
54 | QString dtEndTimeStr() const; | 55 | QString dtEndTimeStr() const; |
55 | /** returns an event's end date as a string formatted according to the | 56 | /** returns an event's end date as a string formatted according to the |
56 | users locale settings */ | 57 | users locale settings */ |
57 | QString dtEndDateStr(bool shortfmt=true) const; | 58 | QString dtEndDateStr(bool shortfmt=true) const; |
58 | /** returns an event's end date and time as a string formatted according | 59 | /** returns an event's end date and time as a string formatted according |
59 | to the users locale settings */ | 60 | to the users locale settings */ |
60 | QString dtEndStr(bool shortfmt=true) const; | 61 | QString dtEndStr(bool shortfmt=true) const; |
61 | void setHasEndDate(bool); | 62 | void setHasEndDate(bool); |
62 | /** Return whether the event has an end date/time. */ | 63 | /** Return whether the event has an end date/time. */ |
63 | bool hasEndDate() const; | 64 | bool hasEndDate() const; |
64 | 65 | ||
65 | /** Return true if the event spans multiple days, otherwise return false. */ | 66 | /** Return true if the event spans multiple days, otherwise return false. */ |
66 | bool isMultiDay() const; | 67 | bool isMultiDay() const; |
67 | 68 | ||
68 | /** set the event's time transparency level. */ | 69 | /** set the event's time transparency level. */ |
69 | void setTransparency(Transparency transparency); | 70 | void setTransparency(Transparency transparency); |
70 | /** get the event's time transparency level. */ | 71 | /** get the event's time transparency level. */ |
71 | Transparency transparency() const; | 72 | Transparency transparency() const; |
72 | 73 | ||
73 | void setDuration(int seconds); | 74 | void setDuration(int seconds); |
74 | 75 | ||
75 | bool contains ( Event*); | 76 | bool contains ( Event*); |
76 | 77 | ||
77 | bool isOverlapping ( Event*, QDateTime*, QDateTime* ); | 78 | bool isOverlapping ( Event*, QDateTime*, QDateTime* ); |
78 | 79 | ||
79 | private: | 80 | private: |
80 | bool accept(Visitor &v) { return v.visit(this); } | 81 | bool accept(Visitor &v) { return v.visit(this); } |
81 | 82 | ||
82 | QDateTime mDtEnd; | 83 | QDateTime mDtEnd; |
83 | bool mHasEndDate; | 84 | bool mHasEndDate; |
84 | Transparency mTransparency; | 85 | Transparency mTransparency; |
85 | }; | 86 | }; |
86 | 87 | ||
87 | bool operator==( const Event&, const Event& ); | 88 | bool operator==( const Event&, const Event& ); |
88 | 89 | ||
89 | 90 | ||
90 | } | 91 | } |
91 | 92 | ||
92 | 93 | ||
93 | #endif | 94 | #endif |