TVPlanIt: Fix display of overlapping "same" events in DayView.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8177 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-12-14 09:50:31 +00:00
parent 2be4c5efdd
commit d62d307e4d
3 changed files with 26 additions and 11 deletions

View File

@ -82,7 +82,6 @@ const
ExtraBarWidth = 2; { The extra, draggable area on either side }
{ of the Contact Grid's horizontal bars. }
CompareTimeEPS = 0.1 * OneSecond; { Epsilon for time comparison, 0.1 sec }
// CompareTimeEPS = 1.0 / (24*60*60*10); { Epsilon for time comparison, 0.1 sec }
cmPerInch = 2.54; { 1 inch is 2.54 cm }

View File

@ -187,10 +187,7 @@ begin
{ 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))
)
(SameTimeOrEarlier(tmpStart, EventStart) and SameTimeOrLater(tmpEnd, EventEnd))
then begin
{ Count this event at this level }
Inc(Levels[EArray[K].Level]);
@ -260,21 +257,28 @@ end;
function TVpDayViewPainter.GetMaxOLEvents(Event: TVpEvent; const EArray: TVpDvEventArray): Integer;
var
K: Integer;
Tmp: TVpEvent;
tmp: TVpEvent;
tmpStart, tmpEnd: TTime;
eventStart, eventEnd: TTime;
begin
result := 1;
K := 0;
Tmp := TVpEvent(EArray[K].Event);
while Tmp <> nil do begin
eventStart := frac(Event.StartTime);
eventEnd := frac(Event.EndTime);
tmp := TVpEvent(EArray[K].Event);
while tmp <> nil do begin
tmpStart := frac(tmp.StartTime);
tmpEnd := frac(tmp.EndTime);
{ 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
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 check the }
{ value of OLLevels. If it is bigger than result, then modify }
{ Result accordingly. }
((frac(Tmp.StartTime) <= frac(Event.StartTime)) and (frac(Tmp.EndTime) >= frac(Event.EndTime)))
(SameTimeOrEarlier(tmpStart, EventStart) and SameTimeOrLater(tmpEnd, EventEnd))
// ((frac(Tmp.StartTime) <= frac(Event.StartTime)) and (frac(Tmp.EndTime) >= frac(Event.EndTime)))
then begin
if EArray[K].OLLevels > result then
Result := EArray[K].OLLevels;

View File

@ -147,6 +147,8 @@ function GetWeekOfYear(ADate: TDateTime): byte;
function IsWeekEnd(ADate: TDateTime): Boolean;
function SameDate(dt1, dt2: TDateTime): Boolean;
function SameTime(t1, t2: TTime): Boolean;
function SameTimeOrEarlier(t1, t2: TTime): Boolean;
function SameTimeOrLater(t1, t2: TTime): Boolean;
function DateInRange(ADate, StartDate, EndDate: TDateTime; IncludeLimits: Boolean): Boolean;
function TimeInRange(ATime, StartTime, EndTime: TDateTime; IncludeLimits: Boolean): Boolean;
@ -806,6 +808,16 @@ begin
Result := SameValue(t1, t2, CompareTimeEps);
end;
function SameTimeOrEarlier(t1, t2: TTime): Boolean;
begin
Result := SameTime(t1, t2) or (t1 < t2);
end;
function SameTimeOrLater(t1, t2: TTime): Boolean;
begin
Result := SameTime(t1, t2) or (t1 > t2);
end;
// Calculates ISO week number (checked with Jan 1, 2016, which is in week 53).
function GetWeekOfYear(ADate: TDateTime): byte;
// wp: was in TvWeekView.