Skip to content

Commit 969bc1f

Browse files
author
César Cardoso
committed
feature/add-ExistGuidInIniFile-in-OpenExternalMod
1 parent 3d44073 commit 969bc1f

3 files changed

Lines changed: 42 additions & 4 deletions

File tree

Src/OpenExternal/C4D.Wizard.OpenExternal.Interfaces.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ interface
1616
['{08D4836C-F789-4228-8773-D9A1DC15AB57}']
1717
function WriteInIniFile(AC4DWizardOpenExternal: TC4DWizardOpenExternal): IC4DWizardOpenExternalModel;
1818
function SaveIconInFolder(const AGuid, APathIcon: string): IC4DWizardOpenExternalModel;
19-
function ReadGuidInIniFile(AGuid: string): TC4DWizardOpenExternal;
19+
//function ReadGuidInIniFile(AGuid: string): TC4DWizardOpenExternal;
2020
procedure ReadIniFile(AProc: TProc<TC4DWizardOpenExternal>);
21+
function ExistGuidInIniFile(const AGuid: string): Boolean;
2122
procedure RemoveGuidInIniFile(const AGuid: string);
2223
end;
2324

Src/OpenExternal/C4D.Wizard.OpenExternal.Model.pas

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ TC4DWizardOpenExternalModel = class(TInterfacedObject, IC4DWizardOpenExternalM
1717
protected
1818
function WriteInIniFile(AC4DWizardOpenExternal: TC4DWizardOpenExternal): IC4DWizardOpenExternalModel;
1919
function SaveIconInFolder(const AGuid, APathIcon: string): IC4DWizardOpenExternalModel;
20-
function ReadGuidInIniFile(AGuid: string): TC4DWizardOpenExternal;
20+
//function ReadGuidInIniFile(AGuid: string): TC4DWizardOpenExternal;
2121
procedure ReadIniFile(AProc: TProc<TC4DWizardOpenExternal>);
22+
function ExistGuidInIniFile(const AGuid: string): Boolean;
2223
procedure RemoveGuidInIniFile(const AGuid: string);
2324
public
2425
class function New: IC4DWizardOpenExternalModel;
@@ -87,7 +88,40 @@ function TC4DWizardOpenExternalModel.SaveIconInFolder(const AGuid, APathIcon: st
8788
TC4DWizardUtils.FileCopy(APathIcon, LFileNameToSave);
8889
end;
8990

90-
function TC4DWizardOpenExternalModel.ReadGuidInIniFile(AGuid: string): TC4DWizardOpenExternal;
91+
function TC4DWizardOpenExternalModel.ExistGuidInIniFile(const AGuid: string): Boolean;
92+
var
93+
LIniFile: TIniFile;
94+
LSections: TStrings;
95+
LSessaoStr: string;
96+
i: Integer;
97+
LGuid: string;
98+
begin
99+
Result := False;
100+
101+
if(AGuid.Trim.ISEmpty)then
102+
Exit;
103+
104+
LIniFile := Self.GetIniFile;
105+
try
106+
LSections := TStringList.Create;
107+
try
108+
LIniFile.ReadSections(LSections);
109+
for i := 0 to Pred(LSections.Count) do
110+
begin
111+
LSessaoStr := LSections[i];
112+
LGuid := LIniFile.Readstring(LSessaoStr, TC4DConsts.OPEN_EXTERNAL_INI_GuidMenuMaster, '');
113+
if(LGuid = AGuid)then
114+
Exit(True);
115+
end;
116+
finally
117+
LSections.Free;
118+
end;
119+
finally
120+
LIniFile.Free;
121+
end;
122+
end;
123+
124+
{function TC4DWizardOpenExternalModel.ReadGuidInIniFile(AGuid: string): TC4DWizardOpenExternal;
91125
var
92126
LIniFile: TIniFile;
93127
begin
@@ -111,7 +145,7 @@ function TC4DWizardOpenExternalModel.ReadGuidInIniFile(AGuid: string): TC4DWizar
111145
finally
112146
LIniFile.Free;
113147
end;
114-
end;
148+
end; }
115149

116150
procedure TC4DWizardOpenExternalModel.ReadIniFile(AProc: TProc<TC4DWizardOpenExternal>);
117151
var

Src/OpenExternal/C4D.Wizard.OpenExternal.View.pas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ procedure TC4DWizardOpenExternalView.btnRemoveClick(Sender: TObject);
408408
if(LGuid.Trim.IsEmpty)then
409409
TC4DWizardUtils.ShowMsgErrorAndAbort('Guid not found');
410410

411+
if(TC4DWizardOpenExternalModel.New.ExistGuidInIniFile(LGuid))then
412+
TC4DWizardUtils.ShowMsgAndAbort('This registration cannot be deleted, as it is linked to other registration(s)');
413+
411414
if(not TC4DWizardUtils.ShowQuestion2('Confirm remove?'))then
412415
Exit;
413416

0 commit comments

Comments
 (0)