mirror of https://gitlab.com/basile.b/dexed.git
libman, update deps on addition, prevent dull update on deletion
This commit is contained in:
parent
bf2d2c64d1
commit
26ed0e0385
|
@ -45,6 +45,7 @@ type
|
||||||
fLibProject: string;
|
fLibProject: string;
|
||||||
fEnabled: boolean;
|
fEnabled: boolean;
|
||||||
fDependencies: TStringList;
|
fDependencies: TStringList;
|
||||||
|
fClients: TStringList;
|
||||||
fModules: TCollection;
|
fModules: TCollection;
|
||||||
fModulesByName: TModulesByName;
|
fModulesByName: TModulesByName;
|
||||||
fHasValidSourcePath: boolean;
|
fHasValidSourcePath: boolean;
|
||||||
|
@ -74,6 +75,7 @@ type
|
||||||
property hasValidLibProject: boolean read fHasValidLibProject;
|
property hasValidLibProject: boolean read fHasValidLibProject;
|
||||||
property hasValidLibSourcePath: boolean read fHasValidSourcePath;
|
property hasValidLibSourcePath: boolean read fHasValidSourcePath;
|
||||||
property dependencies: TStringList read fDependencies;
|
property dependencies: TStringList read fDependencies;
|
||||||
|
property clients: TStringList read fClients;
|
||||||
property modules: TCollection read fModules;
|
property modules: TCollection read fModules;
|
||||||
property moduleByIndex[value: integer]: TModuleInfo read getModule;
|
property moduleByIndex[value: integer]: TModuleInfo read getModule;
|
||||||
end;
|
end;
|
||||||
|
@ -96,7 +98,7 @@ type
|
||||||
procedure setCollection(value: TCollection);
|
procedure setCollection(value: TCollection);
|
||||||
procedure updateItemsByAlias;
|
procedure updateItemsByAlias;
|
||||||
function getLibrariesCount: integer;
|
function getLibrariesCount: integer;
|
||||||
procedure FPOObservedChanged(ASender : TObject; Operation : TFPObservedOperation; Data : Pointer);
|
procedure FPOObservedChanged(ASender: TObject; Operation: TFPObservedOperation; Data : Pointer);
|
||||||
published
|
published
|
||||||
property libraries: TCollection read fCollection write setCollection;
|
property libraries: TCollection read fCollection write setCollection;
|
||||||
public
|
public
|
||||||
|
@ -163,6 +165,9 @@ begin
|
||||||
fModules := TCollection.Create(TModuleInfo);
|
fModules := TCollection.Create(TModuleInfo);
|
||||||
fModulesByName := TModulesByName.create;
|
fModulesByName := TModulesByName.create;
|
||||||
fDependencies := TStringList.Create;
|
fDependencies := TStringList.Create;
|
||||||
|
fClients := TStringList.Create;
|
||||||
|
fDependencies.Duplicates := dupIgnore;
|
||||||
|
fClients.Duplicates := dupIgnore;
|
||||||
fEnabled:=true;
|
fEnabled:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -171,6 +176,7 @@ begin
|
||||||
fModulesByName.Free;
|
fModulesByName.Free;
|
||||||
fDependencies.Free;
|
fDependencies.Free;
|
||||||
fModules.Free;
|
fModules.Free;
|
||||||
|
fClients.Free;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -316,7 +322,7 @@ var
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
fItemsByAlias:= TItemsByAlias.create;
|
fItemsByAlias := TItemsByAlias.create;
|
||||||
fCollection := TCollection.Create(TLibraryItem);
|
fCollection := TCollection.Create(TLibraryItem);
|
||||||
fCollection.FPOAttachObserver(self);
|
fCollection.FPOAttachObserver(self);
|
||||||
fname := getCoeditDocPath + libFname;
|
fname := getCoeditDocPath + libFname;
|
||||||
|
@ -430,13 +436,35 @@ end;
|
||||||
|
|
||||||
procedure TLibraryManager.FPOObservedChanged(ASender: TObject; Operation:
|
procedure TLibraryManager.FPOObservedChanged(ASender: TObject; Operation:
|
||||||
TFPObservedOperation; Data: Pointer);
|
TFPObservedOperation; Data: Pointer);
|
||||||
|
var
|
||||||
|
i,j: integer;
|
||||||
|
lib: TLibraryItem;
|
||||||
|
cli: TLibraryItem;
|
||||||
begin
|
begin
|
||||||
if (Operation = ooDeleteItem) and data.isNotNil and
|
if data.isNil then
|
||||||
fItemsByAlias.contains(TLibraryItem(data).libAlias) then
|
exit;
|
||||||
|
lib := TLibraryItem(data);
|
||||||
|
case operation of
|
||||||
|
ooDeleteItem: if fItemsByAlias.contains(lib.libAlias) then
|
||||||
begin
|
begin
|
||||||
fItemsByAlias.delete(TLibraryItem(data).libAlias);
|
fItemsByAlias.delete(lib.libAlias);
|
||||||
|
for i:= 0 to lib.clients.Count-1 do
|
||||||
|
begin
|
||||||
|
cli := libraryByAlias[lib.clients[i]];
|
||||||
|
if assigned(cli) then
|
||||||
|
begin
|
||||||
|
j := cli.dependencies.IndexOf(lib.libAlias);
|
||||||
|
if j <> -1 then
|
||||||
|
cli.dependencies.Delete(j);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
ooAddItem:
|
||||||
|
begin
|
||||||
|
fItemsByAlias.insert(lib.libAlias, lib);
|
||||||
updateCrossDependencies;
|
updateCrossDependencies;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLibraryManager.getLibraryByIndex(index: integer): TLibraryItem;
|
function TLibraryManager.getLibraryByIndex(index: integer): TLibraryItem;
|
||||||
|
@ -645,6 +673,11 @@ var
|
||||||
dep: TLibraryItem;
|
dep: TLibraryItem;
|
||||||
imp: string;
|
imp: string;
|
||||||
begin
|
begin
|
||||||
|
for i := 0 to fCollection.Count-1 do
|
||||||
|
begin
|
||||||
|
lib := libraryByIndex[i];
|
||||||
|
lib.clients.Clear;
|
||||||
|
end;
|
||||||
for i := 0 to fCollection.Count-1 do
|
for i := 0 to fCollection.Count-1 do
|
||||||
begin
|
begin
|
||||||
lib := libraryByIndex[i];
|
lib := libraryByIndex[i];
|
||||||
|
@ -669,6 +702,7 @@ begin
|
||||||
if lib.dependencies.IndexOf(dep.libAlias) > -1 then
|
if lib.dependencies.IndexOf(dep.libAlias) > -1 then
|
||||||
continue;
|
continue;
|
||||||
lib.dependencies.Add(dep.libAlias);
|
lib.dependencies.Add(dep.libAlias);
|
||||||
|
dep.clients.Add(lib.libAlias);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue