tvplanit: add TVpResource.OverlayResources as alternate method to add overlay groups. Update FullDemo.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8168 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-12-04 19:01:07 +00:00
parent 2757d26671
commit bb91c39431
8 changed files with 219 additions and 33 deletions

View File

@ -68,6 +68,7 @@ type
{ forward declarations }
TVpResource = class;
TVpResourceGroup = class;
TVpResourceArray = array of TVpResource;
TVpTasks = class;
TVpSchedule = class;
TVpEvent = class;
@ -150,6 +151,8 @@ type
constructor Create(Owner: TVpResources);
destructor Destroy; override;
procedure GetResourceGroups(AList: TList);
function OverlayResources(const AResources: TVpResourceArray;
ACaption: String = ''): TVpResourceGroup;
property Loading: Boolean read FLoading write FLoading;
property Changed: Boolean read FChanged write SetChanged;
property Deleted: Boolean read FDeleted write SetDeleted;
@ -1012,6 +1015,48 @@ begin
end;
end;
{ Overlays the resources listed in the array AResources and creates a
resource group named according to ACaption (or, if ACaption is empty, the
comma-separated list of the individual resource names).
If a resource group if this name already exists its contained resources are
replaced by the new ones.
When the array is empty, the overlay group with this caption is cleared. }
function TVpResource.OverlayResources(const AResources: TVpResourceArray;
ACaption: String = ''): TVpResourceGroup;
var
grp: TVpResourceGroup;
i: Integer;
begin
// Use resource descriptions if ACaption is not specified or empty.
if ACaption = '' then
begin
ACaption := FDescription;
for i := Low(AResources) to High(AResources) do
if AResources[i] <> nil then
ACaption := ACaption + ', ' + AResources[i].Description;
end;
// Enforce unique group name
grp := FOwner.FindResourceGroupByName(ACaption);
if grp = nil then
begin
grp := TVpResourceGroup.Create(FOwner, FResourceID, ACaption);
FOwner.FResourceGroups.Add(grp);
end else
grp.Clear; // Make sure that the group is empty before overlaying resources
// Add resources to group
for i := Low(AResources) to High(AResources) do
grp.AddID(AResources[i].ResourceID);
FGroup := grp;
Result := grp;
// Repaint the events
TVpCustomDatastore(FOwner.FOwner).RefreshEvents;
end;
procedure TVpResource.SetContacts(const Value: TVpContacts);
begin
FContacts := Value;
@ -1093,7 +1138,7 @@ begin
FCaption := ACaption;
FPattern := opBDiagonal;
FReadOnly := true;
FShowDetails := [odResource];
FShowDetails := [odResource, odEventDescription];
Clear;
end;

View File

@ -927,7 +927,7 @@ begin
exit;
grp := Datastore.Resource.Group;
showDetails := (grp <> nil) and (odEventDescription in grp.ShowDetails);
showDetails := (grp <> nil) and (grp.ShowDetails <> []);
isOverlayed := AEvent.IsOverlayed;
timefmt := GetTimeFormatStr(TimeFormat);