From d4fd4f420e7a5f5c8a31b888e42a05f8d098daef Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 9 Oct 2023 22:46:32 +0000 Subject: [PATCH] TvPlanIt: Fix double-click on event in hour mode. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8944 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/examples/gantt/data.ini | 1 + .../examples/gantt/ganttview_demo.lpi | 5 ----- components/tvplanit/source/vpganttview.pas | 22 +++++++++++++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/components/tvplanit/examples/gantt/data.ini b/components/tvplanit/examples/gantt/data.ini index e8db69a88..34d3ea597 100644 --- a/components/tvplanit/examples/gantt/data.ini +++ b/components/tvplanit/examples/gantt/data.ini @@ -13,3 +13,4 @@ Version=v105 1842424188={StartTime:2022/08/02 08:00:00}|{EndTime:2022/08/04 16:00:00}|{ResourceID:1178568021}|{Description:Phase 5}|{Category:1}|{AllDayEvent:true}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{CustomInterval:0} 1819459250={StartTime:2022/08/03}|{EndTime:2022/08/11}|{ResourceID:1178568021}|{Description:Phase 6}|{Category:0}|{AllDayEvent:true}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{CustomInterval:0} 1339092840={StartTime:2022/08/10}|{EndTime:2022/08/16}|{ResourceID:1178568021}|{Description:Phase 7}|{Category:3}|{AllDayEvent:true}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{CustomInterval:0} +1170127712={StartTime:2023/10/10 08:00:00}|{EndTime:2023/10/10 16:00:00}|{ResourceID:1178568021}|{Description:TEST ABC}|{Category:0}|{AllDayEvent:false}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{CustomInterval:0} diff --git a/components/tvplanit/examples/gantt/ganttview_demo.lpi b/components/tvplanit/examples/gantt/ganttview_demo.lpi index a64395c2b..009648c14 100644 --- a/components/tvplanit/examples/gantt/ganttview_demo.lpi +++ b/components/tvplanit/examples/gantt/ganttview_demo.lpi @@ -64,11 +64,6 @@ - - - - - diff --git a/components/tvplanit/source/vpganttview.pas b/components/tvplanit/source/vpganttview.pas index c761c190b..bb4bffa30 100644 --- a/components/tvplanit/source/vpganttview.pas +++ b/components/tvplanit/source/vpganttview.pas @@ -4,7 +4,7 @@ unit VpGanttView; {$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined} interface -uses +uses lazloggerbase, LCLType, LCLIntf, LMessages, Classes, SysUtils, Graphics, Types, Controls, StdCtrls, Menus, Forms, VpConst, VpMisc, VpBase, VpBaseDS, VpData; @@ -1197,10 +1197,27 @@ end; function TVpGanttView.GetDateTimeAtCoord(X: Integer): TDateTime; var c: Integer; + dayIdx: Integer; + dayPos: Integer; + dayWidth: Integer; + timePart: TTime; begin c := GetColAtCoord(X); if (c >= 0) and (c < ColCount) then - Result := GetDateOfCol(c) + begin + Result := GetDateOfCol(c); + X := X - FFixedColWidth; + dayWidth := CalcDaysWidth(1); + if HourMode then + begin + dayIdx := ColToDateIndex(c); + dayPos := FDayRecords[dayIdx].Rect.Left - FFixedColWidth; + dec(dayPos, FLeftCol * FColWidth); + timePart := (((X - dayPos) / dayWidth) * HoursPerDay + ord(FStartHour)) / 24; + end else + timePart := frac(X / dayWidth); + Result := Result + timePart; + end else Result := NO_DATE; end; @@ -1706,6 +1723,7 @@ begin dt := GetDateTimeAtCoord(X); if dt <> NO_DATE then SetActiveDate(dt); + Invalidate; end;