Changeset View
Changeset View
Standalone View
Standalone View
korganizer/koeventpopupmenu.cpp
Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | if ( !mCalendar ) { | ||||
return; | return; | ||||
} | } | ||||
const bool hasChangeRights = mCalendar->hasRight( mCurrentIncidence, Akonadi::Collection::CanChangeItem ); | const bool hasChangeRights = mCalendar->hasRight( mCurrentIncidence, Akonadi::Collection::CanChangeItem ); | ||||
KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( mCurrentIncidence ); | KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( mCurrentIncidence ); | ||||
Q_ASSERT( incidence ); | Q_ASSERT( incidence ); | ||||
if ( incidence->recurs() ) { | if ( incidence->recurs() ) { | ||||
const KDateTime thisDateTime( qd, CalendarSupport::KCalPrefs::instance()->timeSpec() ); | // getNextDateTime returns strictly later than the given datetime, so if an event starts a 0:00 we need to set one second before, that. | ||||
const KDateTime thisDateTime( qd.addDays(-1), QTime(23,59,59), CalendarSupport::KCalPrefs::instance()->timeSpec() ); | |||||
mollekopf: This seems to break isLastOccurrence just below? We're trying to figure out if qd is the last… | |||||
knaussAuthorUnsubmitted Not Done Inline ActionsWell in this case it does not matter much because we only test !( isFirstOccurrence && isLastOccurrence ), that is only true for an item that is not a recurrenting one. But yes better fix the code, because it will be copied around :D knauss: Well in this case it does not matter much because we only test !( isFirstOccurrence &&… | |||||
const bool isLastOccurrence = | const bool isLastOccurrence = | ||||
!incidence->recurrence()->getNextDateTime( thisDateTime ).isValid(); | !incidence->recurrence()->getNextDateTime( thisDateTime ).isValid(); | ||||
const bool isFirstOccurrence = | const bool isFirstOccurrence = | ||||
!incidence->recurrence()->getPreviousDateTime( thisDateTime ).isValid(); | !incidence->recurrence()->getPreviousDateTime( thisDateTime ).isValid(); | ||||
mDissociateOccurrences->setEnabled( | mDissociateOccurrences->setEnabled( | ||||
!( isFirstOccurrence && isLastOccurrence ) && hasChangeRights ); | !( isFirstOccurrence && isLastOccurrence ) && hasChangeRights ); | ||||
} | } | ||||
Show All 22 Lines | void KOEventPopupMenu::popupShow() | ||||
if ( CalendarSupport::hasIncidence( mCurrentIncidence ) ) { | if ( CalendarSupport::hasIncidence( mCurrentIncidence ) ) { | ||||
emit showIncidenceSignal( mCurrentIncidence ); | emit showIncidenceSignal( mCurrentIncidence ); | ||||
} | } | ||||
} | } | ||||
void KOEventPopupMenu::popupEdit() | void KOEventPopupMenu::popupEdit() | ||||
{ | { | ||||
if ( CalendarSupport::hasIncidence( mCurrentIncidence ) ) { | if ( CalendarSupport::hasIncidence( mCurrentIncidence ) ) { | ||||
emit editIncidenceSignal( mCurrentIncidence, KDateTime() ); | const KCalCore::Incidence::Ptr inc = CalendarSupport::incidence(mCurrentIncidence); | ||||
KDateTime occurenceDate; | |||||
if ( inc->recurs() ) { | |||||
// We only have the currentDate and need to look for the occurence at this day | |||||
// getNextDateTime returns strictly later than the given datetime, so if an event starts a 0:00 we need to set one second before, that. | |||||
const KDateTime thisDateTime( mCurrentDate.addDays(-1), QTime(23,59,59), CalendarSupport::KCalPrefs::instance()->timeSpec() ); | |||||
occurenceDate = inc->recurrence()->getNextDateTime(thisDateTime); | |||||
} | |||||
emit editIncidenceSignal( mCurrentIncidence, occurenceDate ); | |||||
} | } | ||||
} | } | ||||
void KOEventPopupMenu::print() | void KOEventPopupMenu::print() | ||||
{ | { | ||||
print( false ); | print( false ); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines |
This seems to break isLastOccurrence just below? We're trying to figure out if qd is the last occurrence by getting the next one, with your change you just get the same occurrence again?
So while the code looks correct to get an occurrence on the date specified by qd, I think you need to do:
const KDateTime thisDateTime = inc->recurrence->getNextDateTime(qd.addDays(-1), QTime(23,59,59), CalendarSupport::KCalPrefs::instance()->timeSpec() ));
On the first line so you end up calling getNextDateTime twice for isLastOccurrence and isFirstOccurrence.