tvplanit: Alternate solution for issue #39061

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9090 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-12-17 23:18:28 +00:00
parent 58b00ac007
commit 7548f46b4f
13 changed files with 674 additions and 58 deletions

View File

@@ -74,6 +74,7 @@ type
FAlarm: TVpICalAlarm;
FCategories: TStrings;
FPickedCategory: Integer;
FOpenEnd: Boolean;
function GetCategory(AIndex: Integer): String;
function GetCategoryCount: Integer;
function GetEndTime(UTC: Boolean): TDateTime;
@@ -103,6 +104,7 @@ type
property RecurrenceByXXX: String read FRecurrenceByXXX write FRecurrenceByXXX;
property PickedCategory: Integer read FPickedCategory write FPickedCategory;
property UID: String read FUID write FUID;
property OpenEnd: Boolean read FOpenEnd;
end;
TVpICalToDo = class(TVpICalEntry)
@@ -175,6 +177,8 @@ type
destructor Destroy; override;
procedure Add(AEntry: TVpICalEntry);
procedure Clear;
function ContainsOpenEndEvents: Boolean;
procedure FixOpenEndEvents(ADuration: TDateTime);
procedure LoadFromFile(const AFileName: String);
procedure LoadFromStream(const AStream: TStream);
procedure SaveToFile(const AFileName: String);
@@ -190,7 +194,7 @@ type
implementation
uses
VpConst, VpBase;
VpConst, VpMisc, VpBase;
const
DATE_FORMAT = 'yyyymmdd';
@@ -490,15 +494,9 @@ begin
end;
end;
end;
{
if (FEndTime = NO_DATE) and (FStartTime <> NO_DATE) then
begin
if FDuration = 0 then
FEndTime := FStartTime + 1.0/24 // 1 hour default
else
FEndTime := FStartTime + FDuration;
end;
}
if (FEndTime = NO_DATE) and ((FDuration = 0) or (FDuration = NO_DATE)) then
FOpenEnd := true;
end;
function TVpICalEvent.Categories: TStrings;
@@ -918,6 +916,33 @@ begin
SetLength(FEntries, 0);
end;
function TVpICalendar.ContainsOpenEndEvents: Boolean;
var
i: Integer;
begin
for i := 0 to High(FEntries) do
if (FEntries[i] is TVpICalEvent) and TVpICalEvent(FEntries[i]).OpenEnd then
exit(true);
Result := false;
end;
procedure TVpICalendar.FixOpenEndEvents(ADuration: TDateTime);
var
i: Integer;
ev: TVpICalEvent;
startTime: TDateTime;
begin
for i := 0 to High(FEntries) do
if (FEntries[i] is TVpICalEvent) then
begin
ev := TVpICalEvent(FEntries[i]);
if ev.OpenEnd then begin
startTime := ev.StartTime[true];
ev.EndTime[true] := startTime + ADuration;
end;
end;
end;
function TVpICalendar.GetCount: Integer;
begin
Result := Length(FEntries);