From 15639aae1aba10731c99666adf0c1a0b08f193fe Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 14 Oct 2022 21:17:20 +0000 Subject: [PATCH] tvplanit: Fix GanttView being unable to select a recurring event. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8560 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpganttview.pas | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/components/tvplanit/source/vpganttview.pas b/components/tvplanit/source/vpganttview.pas index 940f99c4c..36d3d42c3 100644 --- a/components/tvplanit/source/vpganttview.pas +++ b/components/tvplanit/source/vpganttview.pas @@ -1218,13 +1218,25 @@ end; function TVpGanttView.GetRowOfEvent(AEvent: TVpEvent): Integer; var i: Integer; + eventRec: PVpGanttEventRec; + found: Boolean; begin for i := 0 to FEventRecords.Count-1 do - if FEventRecords[i]^.Event = AEvent then + begin + eventRec := FEventRecords[i]; + if (eventRec^.Event = AEvent) then begin - Result := i; - exit; + if AEvent.RepeatCode = rtNone then + found := true + else + found := (DatePart(eventRec^.StartTime) <= FActiveDate) and (DatePart(eventRec^.EndTime) >= FActiveDate); + if found then + begin + Result := i; + exit; + end; end; + end; Result := -1; end; @@ -1591,7 +1603,13 @@ begin // Find the active row. This is the row with the active event. if eventRec^.Event = FActiveEvent then - FActiveRow := i; + begin + if FActiveEvent.RepeatCode = rtNone then + FActiveRow := i + else + if (DatePart(eventRec^.StartTime) <= FActiveDate) and (DatePart(eventRec^.EndTime) >= FActiveDate) then + FActiveRow := i; + end; // Prepare for next row y1 := y2; @@ -1843,6 +1861,7 @@ begin ScrollDateIntoView(FActiveDate); FActiveCol := trunc(FActiveDate) - trunc(FRealStartDate); + Invalidate; if (not FInLinkHandler) and (ControlLink <> nil) then @@ -1851,6 +1870,8 @@ begin end; procedure TVpGanttView.SetActiveEvent(AValue: TVpEvent); +var + i:Integer; begin if FActiveEvent <> AValue then begin