diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp --- a/korganizer/koeventpopupmenu.cpp +++ b/korganizer/koeventpopupmenu.cpp @@ -145,11 +145,11 @@ KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( mCurrentIncidence ); Q_ASSERT( incidence ); 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 bool isLastOccurrence = - !incidence->recurrence()->getNextDateTime( thisDateTime ).isValid(); + !incidence->recurrence()->getNextDateTime(KDateTime(qd.addDays(-1), QTime(23,59,59), CalendarSupport::KCalPrefs::instance()->timeSpec())).isValid(); const bool isFirstOccurrence = - !incidence->recurrence()->getPreviousDateTime( thisDateTime ).isValid(); + !incidence->recurrence()->getPreviousDateTime(KDateTime(qd, QTime(0,0,0), CalendarSupport::KCalPrefs::instance()->timeSpec())).isValid(); mDissociateOccurrences->setEnabled( !( isFirstOccurrence && isLastOccurrence ) && hasChangeRights ); } @@ -184,7 +184,15 @@ void KOEventPopupMenu::popupEdit() { 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 ); } }