TvPlanIt: Deletion of a resource deletes also the associated events, contacts and tasks. Tested with all database datastores. Update datastore sample projects.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8947 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-10-10 22:24:46 +00:00
parent f54a1641df
commit f0d8344fee
19 changed files with 611 additions and 692 deletions

View File

@@ -277,6 +277,10 @@ type
procedure LinkToControls(AOwner: TComponent);
procedure UnlinkFromControls(AOwner: TComponent);
procedure InternalPurgeContacts(Res: TVpResource); virtual;
procedure InternalPurgeEvents(Res: TVpResource); virtual;
procedure InternalPurgeTasks(Res: TVpResource); virtual;
property AutoConnect: Boolean read FAutoConnect write SetAutoConnect default false;
property AutoCreate: Boolean read FAutoCreate write FAutoCreate default true;
@@ -948,6 +952,24 @@ begin
NotifyDependents;
end;
procedure TVpCustomDataStore.InternalPurgeContacts(Res: TVpResource);
begin
// Must be overridden by descendants to remove the contacts of the given
// resource from the external storage
end;
procedure TVpCustomDataStore.InternalPurgeEvents(Res: TVpResource);
begin
// Must be overridden by descendants to remove the events of the given
// resource from the external storage
end;
procedure TVpCustomDataStore.InternalPurgeTasks(Res: TVpResource);
begin
// Must be overridden by descendants to remove the tasks of the given
// resource from the external storage
end;
procedure TVpCustomDataStore.PurgeResource(Res: TVpResource);
begin
Unused(Res);
@@ -957,23 +979,35 @@ end;
procedure TVpCustomDataStore.PurgeEvents(Res: TVpResource);
begin
Res.Schedule.ClearEvents;
if not Loading then
NotifyDependents;
if Res <> nil then
begin
InternalPurgeEvents(Res);
Res.Schedule.ClearEvents;
if not Loading then
NotifyDependents;
end;
end;
procedure TVpCustomDataStore.PurgeContacts(Res: TVpResource);
begin
Res.Contacts.ClearContacts;
if not Loading then
NotifyDependents;
if Res <> nil then
begin
InternalPurgeContacts(Res);
Res.Contacts.ClearContacts;
if not Loading then
NotifyDependents;
end;
end;
procedure TVpCustomDataStore.PurgeTasks(Res: TVpResource);
begin
Res.Tasks.ClearTasks;
if not Loading then
NotifyDependents;
if Res <> nil then
begin
InternalPurgeTasks(Res);
Res.Tasks.ClearTasks;
if not Loading then
NotifyDependents;
end;
end;
procedure TVpCustomDatastore.UpdateGroupEvents;