From 7ac4c2769ebac122475fa13d43b1321ce232b727 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 31 Aug 2022 20:47:45 +0000 Subject: [PATCH] tvplanit: Fix date of new event when created from WeekView (was on current day rather than selected day). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8431 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpganttview.pas | 2 +- components/tvplanit/source/vpweekview.pas | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/components/tvplanit/source/vpganttview.pas b/components/tvplanit/source/vpganttview.pas index 9b1ef685e..e2414a82b 100644 --- a/components/tvplanit/source/vpganttview.pas +++ b/components/tvplanit/source/vpganttview.pas @@ -1167,7 +1167,7 @@ begin begin FEndDate := trunc(ADate); FColCount := GetNumDays; - SetLeftCol(MaxInt); + SetLeftCol(FColCount - 1 - FVisibleCols); end else if ADate < FStartDate + FLeftCol then SetLeftCol(trunc(ADate) - trunc(FStartDate)) diff --git a/components/tvplanit/source/vpweekview.pas b/components/tvplanit/source/vpweekview.pas index 3c40c10b1..e8959274e 100644 --- a/components/tvplanit/source/vpweekview.pas +++ b/components/tvplanit/source/vpweekview.pas @@ -1391,24 +1391,27 @@ var EndTime: TDateTime; begin if ReadOnly or (not CheckCreateResource) or - (not Assigned(DataStore) ) or (not Assigned(DataStore.Resource)) + (not Assigned(DataStore)) or (not Assigned(DataStore.Resource)) then Exit; - StartTime := NextFullHour(Now()); { Default start time: next full hour } + // Default start time: next full hour on the active day. // Be careful: By taking the next full hour we may advance to the next day - // here which is very confusing to the user who had clicked on the - // previous day. In this case we go back by one hour (--> 23:00) + // here which is very confusing to the user who had selected the previous day. + // In this case we go back by one hour (--> 23:00) + StartTime := NextFullHour(FActiveDate + Time()); if Trunc(StartTime) <> FActiveDate then StartTime := StartTime - OneHour; - EndTime := StartTime + 30 / MinutesInDay; { StartTime + 30 minutes } + + // Default end time: Start time + 30 minutes + EndTime := StartTime + 30 * OneMinute; ActiveEvent := DataStore.Resource.Schedule.AddEvent( DataStore.GetNextID('Events'), StartTime, EndTime ); - { edit this new event } + // Edit this new event wvSpawnEventEditDialog(True); end;