You've already forked lazarus-ccr
TvPlanIt: Attempting to fix missing events in day view having exactly equal start and end times.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8176 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -153,35 +153,44 @@ function TVpDayViewPainter.CountOverlappingEvents(Event: TVpEvent;
|
||||
const EArray: TVpDvEventArray): Integer;
|
||||
var
|
||||
K, SelfLevel: Integer;
|
||||
Tmp: TVpEvent;
|
||||
tmp: TVpEvent;
|
||||
Levels: array of Integer = nil;
|
||||
EventStart, EventEnd: TTime;
|
||||
tmpStart, tmpEnd: TTime;
|
||||
begin
|
||||
{ initialize the levels array }
|
||||
Result := 0;
|
||||
|
||||
EventStart := frac(Event.StartTime);
|
||||
EventEnd := frac(Event.EndTime);
|
||||
|
||||
{ Initialize the levels array }
|
||||
SetLength(Levels, MaxEventDepth);
|
||||
for K := 0 to pred(MaxEventDepth) do
|
||||
Levels[K] := 0;
|
||||
result := 0;
|
||||
{ First, simply count the number of overlapping events. }
|
||||
K := 0;
|
||||
SelfLevel := -1;
|
||||
Tmp := TVpEvent(EArray[K].Event);
|
||||
while Tmp <> nil do begin
|
||||
if Tmp = Event then begin
|
||||
tmp := TVpEvent(EArray[K].Event);
|
||||
while tmp <> nil do begin
|
||||
if tmp = Event then begin
|
||||
SelfLevel := K;
|
||||
Inc(K);
|
||||
Tmp := TVpEvent(EArray[K].Event);
|
||||
tmp := TVpEvent(EArray[K].Event);
|
||||
Continue;
|
||||
end;
|
||||
|
||||
{ if the Tmp event's StartTime or EndTime falls within the range of }
|
||||
{ Event... }
|
||||
if TimeInRange(frac(Tmp.StartTime), frac(Event.StartTime), frac(Event.EndTime), false) or
|
||||
TimeInRange(frac(Tmp.EndTime), frac(Event.StartTime), frac(Event.EndTime), false) or
|
||||
{ or the Tmp event's StartTime is before or equal to the Event's }
|
||||
{ start time AND its end time is after or equal to the Event's }
|
||||
{ end time, then the events overlap and we will need to increment }
|
||||
{ the value of K. }
|
||||
((frac(Tmp.StartTime) <= frac(Event.StartTime)) and (frac(Tmp.EndTime) >= frac(Event.EndTime)))
|
||||
tmpStart := frac(tmp.StartTime);
|
||||
tmpEnd := frac(tmp.EndTime);
|
||||
|
||||
{ if the Tmp event's StartTime or EndTime falls within the range of Event... }
|
||||
if TimeInRange(tmpStart, EventStart, EventEnd, false) or
|
||||
TimeInRange(tmpEnd, EventStart, EventEnd, false) or
|
||||
{ or the Tmp event's StartTime is before or equal to the Event's }
|
||||
{ start time AND its end time is after or equal to the Event's }
|
||||
{ end time, then the events overlap and we will need to increment }
|
||||
{ the value of K. }
|
||||
(
|
||||
(SameTime(tmpStart, EventStart) or (tmpStart < EventStart)) and
|
||||
(SameTime(tmpEnd, EventEnd) or (tmpEnd > EventEnd))
|
||||
)
|
||||
then begin
|
||||
{ Count this event at this level }
|
||||
Inc(Levels[EArray[K].Level]);
|
||||
@ -189,8 +198,9 @@ begin
|
||||
end;
|
||||
|
||||
Inc(K);
|
||||
Tmp := TVpEvent(EArray[K].Event);
|
||||
tmp := TVpEvent(EArray[K].Event);
|
||||
end;
|
||||
|
||||
{ Then adjust count for overlapping events which share a level. }
|
||||
for K := 0 to pred(MaxEventDepth) do begin
|
||||
if K = SelfLevel then Continue;
|
||||
@ -1891,7 +1901,7 @@ var
|
||||
event: TVpEvent;
|
||||
level: Integer;
|
||||
I, J: Integer;
|
||||
thisTime: TTime;
|
||||
thisTime, tStart, tEnd: TTime;
|
||||
begin
|
||||
{ Set the event array's max size }
|
||||
SetLength(EventArray, MaxVisibleEvents); // EventArray is global within painter
|
||||
@ -1906,10 +1916,10 @@ begin
|
||||
|
||||
EventList := TList.Create;
|
||||
try
|
||||
{Get all of the events for this day}
|
||||
FDayView.DataStore.Resource.Schedule.EventsByDate(ARenderDate, EventList);
|
||||
|
||||
{ Discard AllDayEvents, because they are drawn separately. }
|
||||
// Get all of the events for this day
|
||||
FDayView.DataStore.Resource.Schedule.EventsByDate(ARenderDate, EventList);
|
||||
|
||||
// Discard AllDayEvents, because they are drawn separately.
|
||||
for I := pred(EventList.Count) downto 0 do begin
|
||||
event := EventList[I];
|
||||
if event.AllDayEvent then
|
||||
@ -1930,8 +1940,12 @@ begin
|
||||
ThisTime := 0.0;
|
||||
while (J < EventList.Count) and (J < MaxVisibleEvents) do begin
|
||||
event := EventList[J];
|
||||
if SameTime(frac(event.StartTime), thisTime) or (frac(event.StartTime) > thisTime) then begin
|
||||
thisTime := frac(event.EndTime);
|
||||
tStart := frac(event.StartTime);
|
||||
tEnd := frac(event.EndTime);
|
||||
|
||||
if SameTime(tStart, thisTime) or (tStart > thisTime) then
|
||||
begin
|
||||
thisTime := tEnd;
|
||||
{ Handle end times of midnight }
|
||||
if thisTime = 0 then
|
||||
thisTime := EncodeTime(23, 59, 59, 0);
|
||||
|
Reference in New Issue
Block a user