You've already forked lazarus-ccr
tvplanit: Improve assignment of resource group to resource.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5146 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -405,16 +405,15 @@ end;
|
||||
|
||||
// Creates a resource group at runtime
|
||||
procedure TMainForm.CreateResourceGroup;
|
||||
const
|
||||
GROUP_NAME = 'Res2 overlayed';
|
||||
var
|
||||
datastore: TVpCustomDatastore;
|
||||
grp: TVpResourceGroup;
|
||||
begin
|
||||
datastore := VpControlLink1.Datastore;
|
||||
datastore.Resources.AddResourceGroup(GROUP_NAME, [1, 2]);
|
||||
grp := datastore.Resources.AddResourceGroup('Res2 overlayed', [1, 2]);
|
||||
if datastore.Resource <> nil then
|
||||
datastore.Resource.Group := GROUP_NAME else
|
||||
datastore.Resource.Group := '';
|
||||
datastore.Resource.Group := grp else
|
||||
datastore.Resource.Group := nil;
|
||||
// Important: This is not called internally so far!
|
||||
datastore.RefreshEvents;
|
||||
end;
|
||||
|
@ -805,22 +805,17 @@ procedure TVpCustomDatastore.UpdateGroupEvents;
|
||||
var
|
||||
i: Integer;
|
||||
event: TVpEvent;
|
||||
grp: TVpResourceGroup;
|
||||
id: Integer;
|
||||
begin
|
||||
Resource.Schedule.ClearGroupEvents;
|
||||
|
||||
if Resource.Group = '' then begin
|
||||
if Resource.Group = nil then begin
|
||||
NotifyDependents;
|
||||
exit;
|
||||
end;
|
||||
|
||||
grp := Resources.FindResourceGroupByName(Resource.Group);
|
||||
if grp = nil then
|
||||
exit;
|
||||
|
||||
for i:=0 to grp.Count-1 do begin
|
||||
id := grp[i].ResourceID;
|
||||
for i:=0 to Resource.Group.Count-1 do begin
|
||||
id := Resource.Group[i].ResourceID;
|
||||
if id = ResourceID then
|
||||
exit;
|
||||
LoadEventsOfResource(id);
|
||||
|
@ -113,7 +113,7 @@ type
|
||||
FSchedule: TVpSchedule;
|
||||
FTasks: TVpTasks;
|
||||
FContacts: TVpContacts;
|
||||
FGroup: String; // Name of ResourceGroup to be overlayed in event list.
|
||||
FGroup: TVpResourceGroup;
|
||||
FActive: Boolean; // Internal flag whether to display this resource
|
||||
FNotes: string;
|
||||
FDescription: string;
|
||||
@ -134,7 +134,7 @@ type
|
||||
procedure SetContacts(const Value: TVpContacts);
|
||||
procedure SetDeleted(Value: Boolean);
|
||||
procedure SetDescription(const Value: string);
|
||||
procedure SetGroup(const AValue: String);
|
||||
procedure SetGroup(const AValue: TVpResourceGroup);
|
||||
procedure SetNotes(const Value: string);
|
||||
procedure SetResourceID(const Value: Integer);
|
||||
procedure SetSchedule(const Value: TVpSchedule);
|
||||
@ -156,7 +156,7 @@ type
|
||||
property Schedule: TVpSchedule read GetSchedule write SetSchedule;
|
||||
property Tasks: TVpTasks read FTasks write SetTasks;
|
||||
property Contacts: TVpContacts read FContacts write SetContacts;
|
||||
property Group: String read FGroup write SetGroup;
|
||||
property Group: TVpResourceGroup read FGroup write SetGroup;
|
||||
|
||||
{$ifdef WITHRTTI}
|
||||
published
|
||||
@ -944,7 +944,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpResource.SetGroup(const AValue: String);
|
||||
procedure TVpResource.SetGroup(const AValue: TVpResourceGroup);
|
||||
begin
|
||||
FGroup := AValue;
|
||||
end;
|
||||
|
@ -1159,13 +1159,8 @@ end;
|
||||
{=====}
|
||||
|
||||
procedure TVpDayView.PopupPickResourceGroupEvent(Sender: TObject);
|
||||
var
|
||||
grp: TVpResourceGroup;
|
||||
begin
|
||||
if TMenuItem(Sender).Tag = 0 then
|
||||
Datastore.Resource.Group := ''
|
||||
else
|
||||
Datastore.Resource.Group := TMenuItem(Sender).Caption;
|
||||
Datastore.Resource.Group := TVpResourceGroup(TMenuItem(Sender).Tag);
|
||||
Datastore.UpdateGroupEvents;
|
||||
end;
|
||||
|
||||
|
@ -164,7 +164,8 @@ begin
|
||||
|
||||
if AEvent.IsOverlayed then begin
|
||||
res := FDayView.Datastore.Resources.GetResource(AEvent.ResourceID);
|
||||
Result := Format('[%s] %s', [res.Description, Result]);
|
||||
if res <> nil then
|
||||
Result := Format('[%s] %s', [res.Description, Result]);
|
||||
end;
|
||||
|
||||
if FDayView.WrapStyle = wsNone then begin
|
||||
|
@ -730,7 +730,7 @@ begin
|
||||
newSubItem.OnClick := AEventHandler;
|
||||
newSubItem.GroupIndex := 1;
|
||||
newSubItem.AutoCheck := true;
|
||||
newSubItem.Checked := datastore.Resource.Group = '';
|
||||
newSubItem.Checked := datastore.Resource.Group = nil;
|
||||
newSubItem.Tag := 0;
|
||||
newItem.Add(newSubItem);
|
||||
|
||||
@ -747,7 +747,7 @@ begin
|
||||
newSubItem.OnClick := AEventHandler;
|
||||
newSubItem.GroupIndex := 1;
|
||||
newSubItem.AutoCheck := true;
|
||||
newSubItem.Checked := (datastore.Resource.Group = grp.Caption);
|
||||
newSubItem.Checked := (datastore.Resource.Group = grp);
|
||||
newSubItem.Tag := PtrInt(grp);
|
||||
newItem.Add(NewSubItem);
|
||||
end;
|
||||
|
@ -1121,13 +1121,8 @@ begin
|
||||
end;
|
||||
|
||||
procedure TVpWeekView.PopupPickResourceGroupEvent(Sender: TObject);
|
||||
var
|
||||
grp: TVpResourceGroup;
|
||||
begin
|
||||
if TMenuItem(Sender).Tag = 0 then
|
||||
Datastore.Resource.Group := ''
|
||||
else
|
||||
Datastore.Resource.Group := TMenuItem(Sender).Caption;
|
||||
Datastore.Resource.Group := TVpResourceGroup(TMenuItem(Sender).Tag);
|
||||
Datastore.UpdateGroupEvents;
|
||||
end;
|
||||
|
||||
|
@ -95,7 +95,8 @@ begin
|
||||
if AEvent.IsOverlayed then
|
||||
begin
|
||||
res := FWeekView.Datastore.Resources.GetResource(AEvent.ResourceID);
|
||||
Result := Format('[%s] %s', [res.Description, Result]);
|
||||
if res <> nil then
|
||||
Result := Format('[%s] %s', [res.Description, Result]);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user