You've already forked lazarus-ccr
tvplanit: Show multiple resources in dayview (some issues).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5144 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -414,6 +414,8 @@ begin
|
|||||||
datastore.Resources.AddResourceGroup(GROUP_NAME, [1, 2]);
|
datastore.Resources.AddResourceGroup(GROUP_NAME, [1, 2]);
|
||||||
if datastore.Resource <> nil then
|
if datastore.Resource <> nil then
|
||||||
datastore.Resource.Group := GROUP_NAME;
|
datastore.Resource.Group := GROUP_NAME;
|
||||||
|
// Important: This is not called internally so far!
|
||||||
|
datastore.RefreshEvents;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||||
|
@ -263,7 +263,7 @@ type
|
|||||||
procedure SetResourceByName(Value: string); virtual; abstract;
|
procedure SetResourceByName(Value: string); virtual; abstract;
|
||||||
|
|
||||||
procedure Load; virtual;
|
procedure Load; virtual;
|
||||||
procedure LoadEvents; virtual; abstract;
|
procedure LoadEvents; virtual;
|
||||||
procedure LoadEventsOfResource(AResID: Integer); virtual; abstract;
|
procedure LoadEventsOfResource(AResID: Integer); virtual; abstract;
|
||||||
procedure LoadContacts; virtual; abstract;
|
procedure LoadContacts; virtual; abstract;
|
||||||
procedure LoadTasks; virtual; abstract;
|
procedure LoadTasks; virtual; abstract;
|
||||||
@ -283,6 +283,8 @@ type
|
|||||||
procedure PostTasks; virtual; abstract;
|
procedure PostTasks; virtual; abstract;
|
||||||
procedure PostResources; virtual; abstract;
|
procedure PostResources; virtual; abstract;
|
||||||
|
|
||||||
|
procedure UpdateGroupEvents; virtual;
|
||||||
|
|
||||||
property Connected : boolean read FConnected write SetConnected;
|
property Connected : boolean read FConnected write SetConnected;
|
||||||
property Loading : Boolean read FLoading write FLoading;
|
property Loading : Boolean read FLoading write FLoading;
|
||||||
property Resource: TVpResource read FResource write SetResource;
|
property Resource: TVpResource read FResource write SetResource;
|
||||||
@ -727,7 +729,17 @@ begin
|
|||||||
FResources.Sort;
|
FResources.Sort;
|
||||||
NotifyDependents;
|
NotifyDependents;
|
||||||
end;
|
end;
|
||||||
{=====}
|
|
||||||
|
{ Load this resource's events into memory }
|
||||||
|
procedure TVpCustomDataStore.LoadEvents;
|
||||||
|
begin
|
||||||
|
if Resource <> nil then begin
|
||||||
|
// Load regular events ...
|
||||||
|
LoadEventsOfResource(Resource.ResourceID);
|
||||||
|
// ... and overlayed events
|
||||||
|
UpdateGroupEvents;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpCustomDataStore.RefreshEvents;
|
procedure TVpCustomDataStore.RefreshEvents;
|
||||||
begin
|
begin
|
||||||
@ -757,7 +769,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
|
|
||||||
{ - Added}
|
|
||||||
procedure TVpCustomDataStore.PurgeResource(Res: TVpResource);
|
procedure TVpCustomDataStore.PurgeResource(Res: TVpResource);
|
||||||
begin
|
begin
|
||||||
Unused(Res);
|
Unused(Res);
|
||||||
@ -789,7 +800,34 @@ begin
|
|||||||
NotifyDependents;
|
NotifyDependents;
|
||||||
end;
|
end;
|
||||||
{=====}
|
{=====}
|
||||||
{ - End}
|
|
||||||
|
procedure TVpCustomDatastore.UpdateGroupEvents;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
event: TVpEvent;
|
||||||
|
grp: TVpResourceGroup;
|
||||||
|
id: Integer;
|
||||||
|
begin
|
||||||
|
Resource.Schedule.ClearGroupEvents;
|
||||||
|
|
||||||
|
if Resource.Group = '' 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;
|
||||||
|
if id = ResourceID then
|
||||||
|
exit;
|
||||||
|
LoadEventsOfResource(id);
|
||||||
|
end;
|
||||||
|
|
||||||
|
NotifyDependents;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpCustomDataStore.RegisterWatcher(Watcher: THandle);
|
procedure TVpCustomDataStore.RegisterWatcher(Watcher: THandle);
|
||||||
var
|
var
|
||||||
|
@ -215,6 +215,7 @@ type
|
|||||||
procedure AllDayEventsByDate(Date: TDateTime; EventList: TList);
|
procedure AllDayEventsByDate(Date: TDateTime; EventList: TList);
|
||||||
procedure BatchUpdate(Value: Boolean);
|
procedure BatchUpdate(Value: Boolean);
|
||||||
procedure ClearEvents;
|
procedure ClearEvents;
|
||||||
|
procedure ClearGroupEvents;
|
||||||
procedure DeleteEvent(Event: TVpEvent);
|
procedure DeleteEvent(Event: TVpEvent);
|
||||||
function EventCountByDay(Value: TDateTime): Integer;
|
function EventCountByDay(Value: TDateTime): Integer;
|
||||||
procedure EventsByDate(Date: TDateTime; EventList: TList);
|
procedure EventsByDate(Date: TDateTime; EventList: TList);
|
||||||
@ -242,6 +243,7 @@ type
|
|||||||
FAlertDisplayed: Boolean;
|
FAlertDisplayed: Boolean;
|
||||||
FAlarmAdvType: TVpAlarmAdvType;
|
FAlarmAdvType: TVpAlarmAdvType;
|
||||||
FRecordID: Integer;
|
FRecordID: Integer;
|
||||||
|
FResourceID: Integer;
|
||||||
FLocation: string;
|
FLocation: string;
|
||||||
FNotes: string;
|
FNotes: string;
|
||||||
FDescription: string;
|
FDescription: string;
|
||||||
@ -284,7 +286,9 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(Owner: TVpSchedule);
|
constructor Create(Owner: TVpSchedule);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
function IsOverlayed: Boolean;
|
||||||
property Owner: TVpSchedule read FOwner;
|
property Owner: TVpSchedule read FOwner;
|
||||||
|
property ResourceID: Integer read FResourceID write FResourceID;
|
||||||
property Loading : Boolean read FLoading write FLoading;
|
property Loading : Boolean read FLoading write FLoading;
|
||||||
property Changed: Boolean read FChanged write SetChanged;
|
property Changed: Boolean read FChanged write SetChanged;
|
||||||
property Deleted: Boolean read FDeleted write SetDeleted;
|
property Deleted: Boolean read FDeleted write SetDeleted;
|
||||||
@ -929,7 +933,6 @@ end;
|
|||||||
procedure TVpResource.SetGroup(const AValue: String);
|
procedure TVpResource.SetGroup(const AValue: String);
|
||||||
begin
|
begin
|
||||||
FGroup := AValue;
|
FGroup := AValue;
|
||||||
FChanged := true;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpResource.SetNotes(const Value: string);
|
procedure TVpResource.SetNotes(const Value: string);
|
||||||
@ -1080,6 +1083,20 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ The event is overlayed if its ResourceID is different from that of the
|
||||||
|
resource to which it belongs. }
|
||||||
|
function TVpEvent.IsOverlayed: Boolean;
|
||||||
|
var
|
||||||
|
res: TVpResource; // resource to which the event belongs
|
||||||
|
begin
|
||||||
|
Result := false;
|
||||||
|
if (FOwner <> nil) then begin
|
||||||
|
res := FOwner.FOwner;
|
||||||
|
if (res <> nil) and (res.ResourceID <> FResourceID) then
|
||||||
|
Result := true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpEvent.SetAlarmAdv(Value: Integer);
|
procedure TVpEvent.SetAlarmAdv(Value: Integer);
|
||||||
begin
|
begin
|
||||||
if Value <> FAlarmAdv then begin
|
if Value <> FAlarmAdv then begin
|
||||||
@ -1369,6 +1386,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TVpSchedule.ClearGroupEvents;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
event: TVpEvent;
|
||||||
|
begin
|
||||||
|
for i := FEventList.Count-1 downto 0 do begin
|
||||||
|
event := TVpEvent(FEventList[i]);
|
||||||
|
if event.IsOverlayed then begin
|
||||||
|
FEventList.Delete(i);
|
||||||
|
event.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpSchedule.BatchUpdate(Value: Boolean);
|
procedure TVpSchedule.BatchUpdate(Value: Boolean);
|
||||||
begin
|
begin
|
||||||
if Value then
|
if Value then
|
||||||
|
@ -150,6 +150,7 @@ function TVpDayViewPainter.BuildEventString(AEvent: TVpEvent;
|
|||||||
var
|
var
|
||||||
maxW: Integer;
|
maxW: Integer;
|
||||||
timeFmt: String;
|
timeFmt: String;
|
||||||
|
res: TVpResource;
|
||||||
begin
|
begin
|
||||||
if FDayView.ShowEventTimes then begin
|
if FDayView.ShowEventTimes then begin
|
||||||
timeFmt := IfThen(FDayView.TimeFormat = tf24Hour, 'h:nn', 'h:nnam/pm');
|
timeFmt := IfThen(FDayView.TimeFormat = tf24Hour, 'h:nn', 'h:nnam/pm');
|
||||||
@ -161,6 +162,11 @@ begin
|
|||||||
end else
|
end else
|
||||||
Result := AEvent.Description;
|
Result := AEvent.Description;
|
||||||
|
|
||||||
|
if AEvent.IsOverlayed then begin
|
||||||
|
res := FDayView.Datastore.Resources.GetResource(AEvent.ResourceID);
|
||||||
|
Result := Format('[%s] %s', [res.Description, Result]);
|
||||||
|
end;
|
||||||
|
|
||||||
if FDayView.WrapStyle = wsNone then begin
|
if FDayView.WrapStyle = wsNone then begin
|
||||||
{ if the string is longer than the availble space then chop off the end
|
{ if the string is longer than the availble space then chop off the end
|
||||||
and place those little '...'s at the end }
|
and place those little '...'s at the end }
|
||||||
@ -829,7 +835,10 @@ begin
|
|||||||
RenderCanvas.Brush.Color := EventCategory.BackgroundColor
|
RenderCanvas.Brush.Color := EventCategory.BackgroundColor
|
||||||
end else
|
end else
|
||||||
RenderCanvas.Brush.Color := WindowColor;
|
RenderCanvas.Brush.Color := WindowColor;
|
||||||
|
if AEvent.IsOverlayed then
|
||||||
|
RenderCanvas.Brush.Style := bsBDiagonal;
|
||||||
TPSFillRect(RenderCanvas, Angle, RenderIn, EventRect);
|
TPSFillRect(RenderCanvas, Angle, RenderIn, EventRect);
|
||||||
|
RenderCanvas.Brush.Style := bsSolid;
|
||||||
|
|
||||||
{ Paint the little area to the left of the text the color corresponding to
|
{ Paint the little area to the left of the text the color corresponding to
|
||||||
the event's category. These colors are used even when printing }
|
the event's category. These colors are used even when printing }
|
||||||
|
@ -78,7 +78,6 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
procedure Load; override;
|
procedure Load; override;
|
||||||
procedure LoadEvents; override;
|
|
||||||
procedure LoadEventsOfResource(AResID: integer); override;
|
procedure LoadEventsOfResource(AResID: integer); override;
|
||||||
procedure LoadContacts; override;
|
procedure LoadContacts; override;
|
||||||
procedure LoadTasks; override;
|
procedure LoadTasks; override;
|
||||||
@ -99,10 +98,8 @@ type
|
|||||||
procedure PurgeTasks(Res: TVpResource); override;
|
procedure PurgeTasks(Res: TVpResource); override;
|
||||||
|
|
||||||
procedure SetResourceByName(Value: string); override;
|
procedure SetResourceByName(Value: string); override;
|
||||||
procedure CreateFieldDefs(const TableName : string;
|
procedure CreateFieldDefs(const TableName: string; FieldDefs: TFieldDefs); virtual;
|
||||||
FieldDefs : TFieldDefs); virtual;
|
procedure CreateIndexDefs(const TableName: string; IndexDefs: TIndexDefs); virtual;
|
||||||
procedure CreateIndexDefs(const TableName : string;
|
|
||||||
IndexDefs : TIndexDefs); virtual;
|
|
||||||
|
|
||||||
published
|
published
|
||||||
{events}
|
{events}
|
||||||
@ -1030,34 +1027,27 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Load this resource's events into memory }
|
{ Load the events of the specified resource into memory. The loaded events are
|
||||||
procedure TVpCustomDBDataStore.LoadEvents;
|
attached to the current resource. Note that if AResID is different from the
|
||||||
begin
|
current resource id then the events are used for overlaying. }
|
||||||
if Resource <> nil then
|
|
||||||
LoadEventsOfResource(Resource.ResourceID);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ Load the events of the specified resource into memory }
|
|
||||||
procedure TVpCustomDBDataStore.LoadEventsOfResource(AResID: Integer);
|
procedure TVpCustomDBDataStore.LoadEventsOfResource(AResID: Integer);
|
||||||
var
|
var
|
||||||
res: TVpResource;
|
|
||||||
Event: TVpEvent;
|
Event: TVpEvent;
|
||||||
F: TField;
|
F: TField;
|
||||||
begin
|
begin
|
||||||
// Find the resource belonging to the specified ID.
|
if Resource <> nil then
|
||||||
res := Resources.GetResource(AResID);
|
|
||||||
if res <> nil then
|
|
||||||
with EventsTable do begin
|
with EventsTable do begin
|
||||||
SetFilterCriteria(EventsTable, true, AResID, TimeRange.StartTime, TimeRange.EndTime);
|
SetFilterCriteria(EventsTable, true, AResID, TimeRange.StartTime, TimeRange.EndTime);
|
||||||
First;
|
First;
|
||||||
while not EventsTable.EOF do begin
|
while not EventsTable.EOF do begin
|
||||||
Event := res.Schedule.AddEvent(
|
Event := Resource.Schedule.AddEvent(
|
||||||
FieldByName('RecordID').AsInteger,
|
FieldByName('RecordID').AsInteger,
|
||||||
FieldByName('StartTime').AsDateTime,
|
FieldByName('StartTime').AsDateTime,
|
||||||
FieldByName('EndTime').AsDateTime
|
FieldByName('EndTime').AsDateTime
|
||||||
);
|
);
|
||||||
if Event <> nil then begin
|
if Event <> nil then begin
|
||||||
Event.Loading := true;
|
Event.Loading := true;
|
||||||
|
Event.ResourceID := AResID;
|
||||||
Event.Description := FieldByName('Description').AsString;
|
Event.Description := FieldByName('Description').AsString;
|
||||||
F := FieldByName('Location');
|
F := FieldByName('Location');
|
||||||
if F <> nil then Event.Location := F.AsString;
|
if F <> nil then Event.Location := F.AsString;
|
||||||
|
@ -573,6 +573,7 @@ begin
|
|||||||
|
|
||||||
if Event <> nil then begin
|
if Event <> nil then begin
|
||||||
Event.Loading := true;
|
Event.Loading := true;
|
||||||
|
Event.ResourceID := AResID;
|
||||||
|
|
||||||
FN1 := GetFieldName(FEventMappings, 'Description');
|
FN1 := GetFieldName(FEventMappings, 'Description');
|
||||||
if (FN1 <> '') then
|
if (FN1 <> '') then
|
||||||
|
Reference in New Issue
Block a user