From 454c96067ca8fdfd53e6360799be767be06786af Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 29 Jun 2016 21:34:45 +0000 Subject: [PATCH] tvplanit: Fix incorrect handling of overnight events. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4869 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpevnteditdlg.pas | 23 ++++++++++++++++++++ components/tvplanit/source/vpweekview.pas | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/components/tvplanit/source/vpevnteditdlg.pas b/components/tvplanit/source/vpevnteditdlg.pas index 4505d1537..4bc760bc0 100644 --- a/components/tvplanit/source/vpevnteditdlg.pas +++ b/components/tvplanit/source/vpevnteditdlg.pas @@ -254,7 +254,28 @@ end; {=====} procedure TDlgEventEdit.OKBtnClick(Sender: TObject); +var + res: Integer; + tStart, tEnd, t: TDateTime; begin + tStart := StartDate.Date + StartTime.Time; + tEnd := EndDate.Date + EndTime.Time; + + if (tStart > tEnd) then begin + res := MessageDlg('Incorrect order of start and end times. Do you want to flip them?', + mtConfirmation, [mbYes, mbNo], 0); + if res = mrYes then begin + t := tStart; + tStart := tEnd; + tEnd := t; + StartDate.Date := trunc(tStart); + StartTime.Time := frac(tStart); + EndDate.Date := trunc(tEnd); + EndTime.Time := frac(tEnd); + end else + exit; + end; + ReturnCode := rtCommit; Close; end; @@ -436,6 +457,7 @@ begin end; StartTime.Color := clWindow; + (* { if the end time is less than the start time then change the end time to } { follow the start time by 30 minutes } if ST > StrToTime(EndTime.Text) then begin @@ -444,6 +466,7 @@ begin else EndTime.Text := FormatDateTime('hh:nn AM/PM', ST + 30 / MinutesInDay); end; + *) end; {=====} diff --git a/components/tvplanit/source/vpweekview.pas b/components/tvplanit/source/vpweekview.pas index 30dbb75df..bb51da848 100644 --- a/components/tvplanit/source/vpweekview.pas +++ b/components/tvplanit/source/vpweekview.pas @@ -785,7 +785,7 @@ begin Exit; wvSetDateByCoord(Point(Msg.XPos, Msg.YPos)); - EventAtCoord (Point (Msg.XPos, Msg.YPos)); + EventAtCoord(Point (Msg.XPos, Msg.YPos)); // if the mouse was pressed down in the client area, then select the cell. if not focused then SetFocus;